I have object1 which has many sub-objects in it. These sub-objects are accessed in the form object1.subobject. I have a function which returns a list of sub-objects of the original object. All I would like to do is iterate through the list and access each sub-object. Something like this:
temp_list = listSubChildren(object1) #Get list of sub-objects
for sub_object in temp_list: #Iterate through list of sub-objects
blah = object1.sub-object #This is where I need help
#Do something with blah #So that I can access and use blah
I looked at similar questions where people used dictionaries and getattr but couldn't get either of those methods to work for this.
temp_list? Also, you probably need to changesub-objecttosub_objectas the former is a SyntaxError I think ...getattrfor this problem. I cannot see why this should not work...blah = object1.getattr(object1,sub_object)?getattris a builtin function, not an instance method -- That one would be__getattr__, but don't call that directly here ...