python -m pdb script.pyPython pdb and Breakpoint Cheat Sheet
Focused reference for pdb commands, breakpoints, stepping, stack frames, and conditional debugging.
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
Starting the Debugger
bash
python
import pdb
import traceback
try:
main()
except Exception:
traceback.print_exc()
pdb.post_mortem()bash
PYTHONBREAKPOINT=0 python app.pybash
PYTHONBREAKPOINT=pdb.set_trace python app.pyInspection and Frames
text
atext
p locals()text
p globals()text
llAutomatically display an expression
Re-evaluate an expression each time execution stops.
textANYwatchinspection
text
display user.balancetext
undisplay 1Advanced Usage
python
import pdb
pdb.run("main()")python
import pdb
pdb.runcall(func, arg1, arg2)Run with custom globals and locals
Control execution namespaces when debugging code strings.
pythonANYpdbcontexts
python
import pdb
pdb.runctx("result = fn(x)", globals(), locals())text
alias pl p locals()More in Python Debugging
Python Profiling and Troubleshooting Cheat Sheet
Profile Python programs, inspect memory and imports, and diagnose slow or stuck processes.
Python Test Debugging Cheat Sheet
pytest and unittest debugging patterns for isolating failures, flaky tests, fixtures, and CI-only issues.
Python Logging and Tracing Cheat Sheet
Reference for Python logging, stack traces, warning visibility, trace hooks, and instrumentation patterns.
Python Debugging Cheat Sheet
Core Python debugging commands, traceback inspection, runtime introspection, and practical troubleshooting workflows.