by rtpg · 13y ago · 0 comments
Instead I have to stick in some print statements and start everything over again.
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt: # allow ctrl-C
raise
except Exception as e:
import sys, traceback, pdb
print e
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
This will catch any exceptions and throw you into PDB in the context where the exception was raised. You probably don't want to leave it in production code, but it's super useful for development. $ python -m pdb yourscript.py
(Pdb) c
Will let you inspect the local scope after an uncaught exception.