I need to check, inside a Python script,
if an object with a
particular ID exists inside a folder.
Right now I'm using the following code:
# this is the folder I want to search
myFolder = container.REQUEST.PARENTS[0].img_folder
# search the folder for an object with ID <object_id>
obj = getattr(myFolder, object_id, None)
if obj is not None:
# there is no such object
else:
# there is an object
with that id
Is there a more efficient way to perform this
operation?
kind regards,
Vitor Varalonga