Mar-17-2020, 06:02 PM
Hi,
I'm trying to add an attribute to a function / method within a class and then change it from within the function.
Couldn't figure out how to do this, while similar approach to a function not in a class works.
Simplified example:
Ok to add attribute to function like this:
I'm trying to add an attribute to a function / method within a class and then change it from within the function.
Couldn't figure out how to do this, while similar approach to a function not in a class works.
Simplified example:
Ok to add attribute to function like this:
def cb0(): self.cb0.data=2 cb0.data=4But fails when adding attribute to function within class like this:
class cam(): def cb1(self): print(self.cb1.data) #--> strangely, this line runs and reads .data self.cb1.data=2 #--> but this line gives an error, stating there is no object 'data' cb1.data=4 a=cam() a.cb1()AttributeError: 'method' object has no attribute 'data'