From Python docs:
sys.excepthook(type, value, traceback)This function prints out a given traceback and exception to
sy
Another option is to use ipython, which I consider a must-have tool for any python developer anyway. Instead of running your script from the shell, run it from ipython with %run. When an exception occurs, you can type %debug to debug it. (There's also an option to automatically debug any exception that occurs, but I forget what it is.)