Skip to content

Instantly share code, notes, and snippets.

@avian2
Created August 10, 2015 17:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avian2/15a67c684de482863b8c to your computer and use it in GitHub Desktop.
Save avian2/15a67c684de482863b8c to your computer and use it in GitHub Desktop.
import traceback
import re
def debug_var(a):
s = traceback.extract_stack(limit=2)[0][3]
g = re.match("\w+\((\w+)\)", s)
print("%s = %r" % (g.group(1), a))
def main():
foo=1
debug_var(foo)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment