14

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...

Thomas K
  • 39,200
  • 7
  • 84
  • 86
Steven Lu
  • 41,389
  • 58
  • 210
  • 364
  • I think i saw somewhere something about SQLite. Maybe once I install that it will start to work? – Steven Lu Jun 29 '13 at 04:49
  • Looks like you've hit [this bug](https://github.com/ipython/ipython/issues/682) or a related one within ipython. – pwaller Sep 22 '13 at 20:02
  • Damn. 3 months and I can't even remember if this problem has been solved or not, I have not been messing about with my one python script that makes use of this. I feel like ipython will simply not remember *anything* if SQLite isn't configured, which would indicate this is a bug if it did remember stuff some of the time. I'll have to investigate this further later; my kickstart script is already set to `pip install` ipython and sqlite (and readline) automatically. @pwaller thanks for linking that, breadcrumbs are good to have – Steven Lu Sep 22 '13 at 20:07
  • @StevenLu Do you have a way around this? – Phani Nov 07 '14 at 22:11
  • @Phani No I have not looked into this anymore. `pudb` looks interesting and I might switch to that, if i ever go back to Python again :) – Steven Lu Nov 08 '14 at 03:50
  • Possible duplicate of [History across ipdb sessions](http://stackoverflow.com/questions/26810905/history-across-ipdb-sessions) – michelesr Nov 24 '16 at 12:27
  • Any updates one this? Has anyone submitted PR for this improvement? – Saim Raza Aug 23 '18 at 07:33

1 Answers1

3

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

Beka
  • 725
  • 6
  • 22