Skip to content

Instantly share code, notes, and snippets.

@pointofpresence
Created April 9, 2022 12:42
Show Gist options
  • Save pointofpresence/957e2c7a9e8c61d40f3be69c291338ae to your computer and use it in GitHub Desktop.
Save pointofpresence/957e2c7a9e8c61d40f3be69c291338ae to your computer and use it in GitHub Desktop.
Python caller name
import inspect
def f1(): f2()
def f2():
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
print('caller name:', calframe[1][3])
f1()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment