Starting ipython from pdb

July 7, 2008 – 1:52 pm

Well this is not so useful now that ipdb exists. Still ipdb sometimes fights with ipython, the ? of ipython doesn’t work, so it might still be useful from time to time.

For those that are used to ipython the python debugger is often frustrating by its limitations: no completion, no function auto-call, no import completion … That’s why before ipdb existed I often ended up launching ipython from the python debugger.

Of course in ipython you won’t have access to the special commands of the debugger but you’ll have all the nice features of ipython. And you’ll always be able to quit ipython with the Quit command to return to pdb.

So the way to start an embedded ipython from pdb is :

from IPython.Shell import IPShellEmbed
IPShellEmbed([])()
 

But this is kinda long. So if you are a good (lazy) programmer you’ll want to create an ipy.py file in your site-package directory (or any other directory in your python path). This file should contain :

from IPython.Shell import IPShellEmbed
shell = IPShellEmbed([])

That way you can start ipython with :

from ipy import shell; shell()
  1. 2 Responses to “Starting ipython from pdb”

  2. Python sucks!
    PHP rocks !

    By Toto Caca on Jul 8, 2008

  3. Thanks Julien for this constructive comment.

    By admin on Jul 9, 2008

Post a Comment