These are chat archives for ipython/ipython

Jul 2015
Jul 29 2015 02:38
hi, there, how can I print the method name once called in a class

say I have a class
class foo(object):
def a(self):
def b(sefl):


f = foo()

and when i call : f.a

it will print something like : 'start executing func : foo.a ....' then execute a , after that, it will print 'done executing func : foo.a ....'

thans a lot
I can implement this by adding a decorate above every method in class foo()
Jul 29 2015 02:46
but it seems ugly when there are more and more methods in class foo
so i wanna ask is there any better and nicer way to handle this problem
thanks a lot
Min RK
Jul 29 2015 05:32
@litaotao You can use a class decorator to effectively decorate all methods, so that you only need one decorator on the whole class. You could also implement it in __getattribute__ which is called when foo.a is requested.