Created
April 9, 2022 12:42
-
-
Save pointofpresence/957e2c7a9e8c61d40f3be69c291338ae to your computer and use it in GitHub Desktop.
Python caller name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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