Getting the caller function name inside another function in Python?
#coding:utf-8
import inspect
def f():
print('i am function f')
print('my parent function is',inspect.stack()[1][3])
def g():
print('i am function g')
f()
def k():
print('i am function k')
f()
g()
k()
i am function g
i am function f
('my parent function is', 'g')
i am function k
i am function f
('my parent function is', 'k')