import inspectdef first(): return second()def second(): return inspect.getouterframes( inspect.currentframe() )[1]first()[3] # 'first'

import inspectdef first(): return second()def second(): return inspect.getouterframes( inspect.currentframe() )[1]first()[3] # 'first'