You just call it from within the function that wants to know the way it was called.
import inspect def foo(): print("hello") print(f"Called as {inspect.stack()[1][4][0]}") bar = foo foo() bar()