This is a draft cheat sheet. It is a work in progress and is not finished yet.
Python 3.7
|
Start debugger inside a Python script |
|
Env Var: Set to skip all breakpoints |
PYTHONBREAKPOINT=ipdb.set_trace
|
Env Var: breakpoint() which debugger to use |
Getting Started
import pdb;pdb.set_trace()
|
Start pdb inside a python script |
python -m pdb <file.py>
|
Start pdb from the command line |
import ipdb;ipdb.set_trace()
|
Start ipdb inside a python script |
|
|
Manual Breakpoints
|
show all breakpoints |
|
set a breakpoint at a line |
b(reak) line_no, condition
|
set a breakpoint at a line, if condition is met |
Stepping
|
step over |
|
step into |
|
continue until current function returns |
|
continue until next breakpoint |
|
next line to be executed (useful for breaking out of loops) |
|
|
Frame Navigation
|
up one level in the stack trace |
|
down one level in the stack trace |
Display
|
print the value of expr |
|
pretty print the value of expr |
|
print the current position and stack trace |
|
print the lines of code around the current line |
|
print args of the current function |
credits
original sheet from: github.com/Kapeli/cheatsheets |
|