Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ipython ipdb, when invoked via ipdb.set_trace(), does not remember the command history while debugging

iPython does remember the command history if I run ipython normally, e.g. to mess around testing basic things in the repl, but I would like to be able to pull up the debugging commands from the previous debug session, and I am doing my debugging by simply running my program as normal, where the program contains

import ipdb
def info(type, value, info):
    import traceback
    traceback.print_exception(type, value, info)
    ipdb.pm()

import sys
sys.excepthook = info
trace = ipdb.set_trace

Which is to set it up so I can write trace() anywhere in my program to start debugging there when I run the program, or for it to automatically start postmortem debugging when it dies on its own.

Python with iPython has been leaps and bounds beyond other languages when it comes to quick code/test iterations and I'm just so close to nirvana at this point...

like image 408
Steven Lu Avatar asked Jun 16 '13 21:06

Steven Lu


People also ask

How do I use IPython for debugging?

IPython has another way to start a debugger. You don't need to modify the source code of any file as we did before. If you run the %run -d filename.py magic command, IPython will execute the filename.py file and put a breakpoint on the first line there. It's just as if you would put the import ipdb; ipdb.

What does IPDB mean in Python?

ipdb, the IPython-enabled Python Debugger, is a third party interative debugger with all pdb's functionality and adds IPython support for the interactive shell, like tab completion, color support, magic functions and much more. You use ipdb just as you use pdb but with an enhanced user experience.

How do I skip a loop in IPDB?

You can use j <line number> (jump) to go to another line.


1 Answers

I use pudb instead. It enables getting to a real ipython shell from the debugger and all the commands there are saved

like image 56
Beka Avatar answered Sep 24 '22 21:09

Beka