[IPython-User] replacing pdb with ipython 0.12

Robert Cimrman cimrman3@ntc.zcu...
Thu Jan 19 09:49:33 CST 2012


On 01/19/12 16:43, Robert Cimrman wrote:
> On 01/19/12 14:51, Lev Givon wrote:
>> Received from Robert Cimrman on Thu, Jan 19, 2012 at 05:18:03AM EST:
>>> Hi!
>>>
>>> Up to ipython 0.10.2, I have used the following code
>>>
>>> import sys
>>> old_excepthook = sys.excepthook
>>>
>>> from IPython.Debugger import Pdb
>>> from IPython.Shell import IPShell
>>> from IPython import ipapi
>>>
>>> def debug():
>>>        shell = IPShell(argv=[''])
>>>        sys.excepthook = old_excepthook
>>>        ip = ipapi.get()
>>>        def_colors = ip.options.colors
>>>        Pdb(def_colors).set_trace(sys._getframe().f_back)
>>>
>>> to replace pdb.set_trace() call - instead I call debug() and get ipython prompt
>>> at the corresponding line of the code, with colors, tab-completion etc.
>>>
>>> How to upgrade the code for>= 0.11?
>>>
>>> r.
>>
>> The following works with 0.11+:
>>
>> http://pypi.python.org/pypi/ipdb
>
> Thanks! That should get me started, although I do not want another dependency.

So now the import command is 'from IPython.core.debugger import Pdb', and to 
get the shell I use:

from IPython.frontend.terminal.embed import InteractiveShellEmbed
ip = InteractiveShellEmbed()

Otherwise it is pretty much the same.

It works well, but in 0.10.2 when I typed some commands in the debugger, they 
were saved in the history - I could reuse them in next debugging session. The 
above code does not update the history (it only sees history from regular 
ipython sessions). Can this be fixed somehow?

Thanks!
r.


More information about the IPython-User mailing list