I am working with objects in Python and all I wanted was to replace the attribute in a for loop to get the data out of the object. Here is my code:
def calculate_something(dictionaryWithObjects):
for attribute in ['attr1', 'attr2', 'attr3']:
dataA1, dataA2 = dictionaryWithObjects['Object1'].attribute
dataB1, dataB2 = dictionaryWithObjects['Object2'].attribute
dataC1, dataC2 = dictionaryWithObjects['Object3'].attribute
So this is more or less what I think I need. I will use the data for calculations afterwards. But it gives an error saying that the object has no attribute called ".attribute". Of course it doesn't, I meant it to replace the 'attr1' in there.
What am I doing wrong?