Skip to content

Instantly share code, notes, and snippets.

@mrskug
Last active November 6, 2017 08:43
Show Gist options
  • Save mrskug/6fec60f18e85a0005afa22312a349b34 to your computer and use it in GitHub Desktop.
Save mrskug/6fec60f18e85a0005afa22312a349b34 to your computer and use it in GitHub Desktop.
Get caller of function in python
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