Inspect the traceback after an exception.
Section: Starting the Debugger
Post-mortem debugging
python
python
import pdb
import traceback
try:
main()
except Exception:
traceback.print_exc()
pdb.post_mortem()Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Starting the Debugger
Route breakpoint() to pdb.set_trace
Set an explicit hook from the environment.
Run with custom globals and locals
Control execution namespaces when debugging code strings.