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.

Revisions

  1. hoffmann revised this gist Aug 26, 2010. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions debug.py
    Original file line number Diff line number Diff line change
    @@ -8,3 +8,5 @@ def debug(s, *args, **kwargs):
    def foo():
    bar = 'world'
    debug('hello {bar}')

    foo()
  2. hoffmann created this gist Aug 26, 2010.
    10 changes: 10 additions & 0 deletions debug.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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}')