Skip to content

Instantly share code, notes, and snippets.

@hoffmann
Created August 26, 2010 22:59
Show Gist options
  • Save hoffmann/552419 to your computer and use it in GitHub Desktop.
Save hoffmann/552419 to your computer and use it in GitHub Desktop.
def debug(s, *args, **kwargs):
c_frame = inspect.getouterframes(inspect.currentframe(), 1)[1][0]
c_args, c_varargs, c_varkw, c_locals = inspect.getargvalues(c_frame)
d = dict(c_locals)
if kwargs: d.update(kwargs)
print s.format(*args, **d)
def foo():
bar = 'world'
debug('hello {bar}')
foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment