P
popov
Look at this code:
class C:
def func():
<caller_of_func>.my_attrib = 1
func = staticmethod(func)
C.func()
c = C()
c.func()
In func, I would like to get C for the first call, and c for the
second one, to be able to add a new attribute to this object (so that
would add the attribute either to the class object or to the
instance). How can I do this ?
I tried to give a look to the inspect module with no luck.
class C:
def func():
<caller_of_func>.my_attrib = 1
func = staticmethod(func)
C.func()
c = C()
c.func()
In func, I would like to get C for the first call, and c for the
second one, to be able to add a new attribute to this object (so that
would add the attribute either to the class object or to the
instance). How can I do this ?
I tried to give a look to the inspect module with no luck.