Show Menu
Cheatography

Python pdb Cheat Sheet by

Python's pdb commands

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)
       
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

            Python 3 Cheat Sheet by Finxter