I want the decorator to add a decorated function to the list, for example:
class My_Class(object): def __init__(self): self.list=[] @decorator def my_function(self) print 'Hi'
I expect my_function to be added to self.list, but I just can't write this decorator. If I try to write it inside My_Class, then I have to use @ self.decorator, and self does not exist, since we are outside of any function. And if I try to write it from My_Class, then I cannot get self from my_function.
I know pretty similar questions, but they are too complicated, and I'm just learning python and decorators.
CGGJE source share