Created
December 8, 2013 17:39
-
-
Save pfigue/7860771 to your computer and use it in GitHub Desktop.
Python Debugging Werkzeugkiste
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 watch(var1): | |
| """ | |
| Helper to watch the value of VARIABLES (not expressions) | |
| in the scope of calling function: | |
| >>> k = 3 | |
| >>> watch('k') | |
| "k" := int, "3" | |
| Won't work with expressions like: | |
| >>> watch('str(k)') | |
| """ | |
| import sys | |
| k = sys._getframe(1) | |
| value = k.f_locals[var1] | |
| print '"%s" := %s, "%s"\n' % (var1, type(value).__name__, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment