Cheatography
https://cheatography.com
Invoking the debugger
import pdb; pdb.set_trace() |
Within the code |
python -m pdb file.py |
From the command line |
Basic commands
p |
print variable value |
pp |
pretty print |
a |
print input args of function |
locals |
show local variables |
n |
next |
s |
step inside a function |
c |
continue |
r |
run until func returns |
<Enter> |
repeat previous command |
l |
print nearby code |
l from,to |
print code between lines |
w |
where am I + traceback |
u |
up the call stack |
d |
down the call stack |
q |
quit |
h |
help |
h command |
info about a command |
|
|
Breakpoints
b 45 |
set on line 45 |
b 45, x == 'abc' |
set with condition |
b |
list current breakpoints |
b funcName |
set breakpoint in function |
b file.py:41 |
set on line 41 of file.py |
cl |
clear all breakpoints |
cl 42 |
clear breakpoint #42 |
tbreak ... |
hit only once, syntax as b
|
disable 42 |
turn off breakpoint #42 |
enable 42 |
enable breakpoint #42 |
ignore 42 [N] |
ignore bp#42 N times |
condition 42 x=='abc' |
set condition to bp (no condition = remove it) |
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets