Created
July 15, 2020 21:41
-
-
Save atucom/35c3896a3a09b754d82145402ddf8e0f to your computer and use it in GitHub Desktop.
Debugging decorator to output function and args
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
def verbose(func): | |
def output_args(*args, **kwargs): | |
print("Called {} with: {}".format(func.__name__, [args, kwargs])) | |
func(*args, **kwargs) | |
return output_args | |
@verbose | |
def say_thing(thing): | |
print(thing) | |
say_thing('yolo') | |
"""Output: | |
Called say_thing with: [('yolo',), {}] | |
yolo | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment