Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 283 Bytes

get-the-callers-method-name-in-the-called-method.md

File metadata and controls

14 lines (13 loc) · 283 Bytes
>>> import inspect
>>> def f1(): f2()
...
>>> def f2():
...   curframe = inspect.currentframe()
...   calframe = inspect.getouterframes(curframe, 2)
...   print('caller name:', calframe[1][3])
...
>>> f1()
caller name: f1

Source