- inspect
- stack
Name of the caller function in Python
examples/advanced/name_of_caller_function.py
import inspect def first(): print("in first") print("Called by", inspect.stack()[1][3]) second() def second(): print("in second") print("Called by", inspect.stack()[1][3]) def main(): first() main()