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
bashANYpdbcli
bash
pythonANYpdbpostmortem
python
import pdb
import traceback
try:
main()
except Exception:
traceback.print_exc()
pdb.post_mortem()bashANYbreakpointenvironment
bash
PYTHONBREAKPOINT=0 python app.pybashANYbreakpointpdb
bash
PYTHONBREAKPOINT=pdb.set_trace python app.pyInspection and Frames
textANYframesarguments
text
atextANYlocalsvariables
text
p locals()textANYglobalsvariables
text
p globals()textANYsource-view
text
lltextANYwatchinspection
text
display user.balancetextANYwatch
text
undisplay 1Advanced Usage
pythonANYpdbembedded
python
import pdb
pdb.run("main()")pythonANYpdbfunctions
python
import pdb
pdb.runcall(func, arg1, arg2)pythonANYpdbcontexts
python
import pdb
pdb.runctx("result = fn(x)", globals(), locals())textANYpdbproductivity
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.