Last active
November 6, 2017 08:43
-
-
Save mrskug/6fec60f18e85a0005afa22312a349b34 to your computer and use it in GitHub Desktop.
Get caller of function in python
This file contains 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 | |
# Gets the function name of the caller | |
# To be used for debug purposes | |
def getCaller(): | |
a = inspect.currentframe() | |
b = inspect.getouterframes(a, 2) | |
print(b[1][3] + " Called by " + b[2][3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment