to self when method name is bound to simple function onlywhen it is an instance of callable classthat class' instance is passed instead technicallypython makes bound method object containing the subject instance only when the method is simple functionnot when it is callable instance of another class using nested functions to decorate methods if you want your function decorators to work on both simple functions and class-level methodsthe most straightforward solution lies in using one of the other state retention solutions described earlier--code your function decorator as nested defsso that you don' depend on single self instance argument to be both the wrapper class instance and the subject class instance the following alternative applies this fix using python nonlocalsrecode this to use function attributes for the changeable calls to use in because decorated methods are rebound to simple functions instead of instance objectspython correctly passes the person object as the first argumentand the decorator propagates it on in the first item of *args to the self argument of the realdecorated methodsa call tracer decorator for both functions and methods def tracer(func)use functionnot class with __call__ calls else "selfis decorator instance onlydef oncall(*args**kwargs)or in + xuse [oncall calls + nonlocal calls calls + print('call % to % (callsfunc __name__)return func(*args**kwargsreturn oncall if __name__ ='__main__'applies to simple functions @tracer def spam(abc)print( cspam tracer(spamoncall remembers spam @tracer def eggs( )return * spam( spam( = = = print(eggs( )runs oncall( applies to class-level method functions tooclass persondef __init__(selfnamepay)self name name self pay pay coding function decorators