Python: How to get the caller's method name in the called method?

Posted by ziang on Stack Overflow See other posts from Stack Overflow or by ziang
Published on 2010-04-16T15:18:59Z Indexed on 2010/04/16 15:23 UTC
Read the original article Hit count: 221

Filed under:

Python: How to get the caller's method name in the called method?

Assume I have 2 methods:

def method1(self):
    ...
    a = A.method2()

def method2(self):
    ...

If I don't want to do any change for method1, how to get the name of the caller (in this example, the name is method1) in method2?

© Stack Overflow or respective owner

Related posts about python