Skip to content

Instantly share code, notes, and snippets.

@enricmcalvo
Last active December 20, 2015 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enricmcalvo/6164464 to your computer and use it in GitHub Desktop.
Save enricmcalvo/6164464 to your computer and use it in GitHub Desktop.
Debugging in IPython

#Debugging in IPython

Declared the function:

def debug(f, *args, **kwargs):
    from pdb import Pdb as OldPdb
    try:
        from IPython.core.debugger import Pdb
        kw = dict(color_scheme='Linux')
    except ImportError:
        Pdb = OldPdb
        kw = {}
    pdb = Pdb(**kw)
    return pdb.runcall(f, *args, **kwargs)

You can invoke it on a function and arguments like so: Debugging in IPython

    debug(test_function, arg1, arg2, named_arg1='hello')

You will get all the interactive IPython goodness as you step through your code.

[Thanks to @atomklein]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment