The self argument is passed as the first argument. Also your MyDecorator is a class that emulates a function. Itβs easier to make it a real feature.
def MyDecorator(method): def wrapper(self, *args, **kwargs): print 'Self is', self return method(self, *args, **kwargs) return wrapper class SomeClass(object): @MyDecorator def f(self): return 42 print SomeClass().f()
user97370
source share