Created
April 19, 2019 13:25
-
-
Save rcj4747/0b2cefa65f4e44cf2e8a3d2a1892ff98 to your computer and use it in GitHub Desktop.
python snippet to print a callers function name and arguments
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 | |
def print_args(): | |
'''Print the callers function name along with argument values''' | |
# TODO: print * and ** args | |
frame, _, _, name, _, _ = inspect.getouterframes(inspect.currentframe())[1] | |
args, _, _, values = inspect.getargvalues(frame) | |
print("%s: %s)" % (name, ["%s=%s" % (i, values[i]) for i in args])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment