# Command line history: import readline histfile = os.path.expanduser("~/.pdb-history") try: readline.read_history_file(histfile) except IOError: pass def savehist(): import readline readline.set_history_length(50) readline.write_history_file(histfile) import atexit atexit.register(savehist) # return to debugger after fatal exception (Python cookbook 14.5): import sys def info(type, value, tb): if hasattr(sys, 'ps1') or not sys.stderr.isatty(): sys.__excepthook__(type, value, tb) import traceback, pdb traceback.print_exception(type, value, tb) print pdb.pm() sys.excepthook = info # Cleanup any variables that could otherwise clutter up the namespace. del atexit, info, readline, rlcompleter, savehist