Python pdb Cheat Sheet

A Programming › Python cheat sheet in English by ralienpp

Python's pdb commands

33,414 views 6,830 downloads 18 Jun 2014 History
4.9 avg · 2 ratings

Invoking the debugger

import pdb; pdb.se­t_t­race()
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
<En­ter>
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

Breakp­oints

b 45
set on line 45
b 45, x == '­abc­'
set with condition
b
list current breakp­oints
b funcName
set breakpoint in function
b file.py:41
set on line 41 of file.py
cl
clear all breakp­oints
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)

Badges

Useful Cheat Sheet Nice Cheat Sheet Good Cheat Sheet Downloaded from Unusual Locations × 1

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.