Created
February 24, 2014 17:46
-
-
Save hexsprite/9193161 to your computer and use it in GitHub Desktop.
Python tracing decorator
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
| def trace(fun): | |
| def decorated(*args, **kwargs): | |
| import traceback | |
| print '-' * 20 | |
| print repr(fun), "\n" | |
| print "args=", repr(args), "kwargs=", repr(kwargs) | |
| traceback.print_stack() | |
| print '-' * 20 | |
| return fun(*args, **kwargs) | |
| return decorated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment