How can I get the class of the method that is wrapped by a decorator with Python 2.7?
With this code:
def timeit(method): def timed(*args, **kw): result = method(*args, **kw) className = ??? print '%s.%s'%(className, method.func_name) #want printed: Test.run return result return timed class Test(object): @timeit def run(self, ): print 'run' a = Test() a.run() I'm not sure what to put for className = ???. I want it to print Test.run.
I've seen similar solutions that use im_class and __ self__ but I don't have either.