The following useful decorator measures the execution time of a function. It also prints the function's name. However, it would be great if it could also print the class name if the function is a method. What is a concise way to get to the full method name a la
def timed(*args, **kw):
ts = time.time()
result = f(*args, **kw)
te = time.time()
print('func:%r args:[%r, %r] took: %2.4f sec' % (f.__name__, args, kw, te-ts))
In : class MyClass(object): ...: def my_method(self): ...: pass ...: In : MyClass.my_method.__qualname__ Out: 'MyClass.my_method'