pdb in action
Lorenzo Mele
greenkey
http://loman.it
Twitter: @greenkey
GitHub: greenkey
LinkedIn: in/lorenzomele
Google: lorenzo.mele
Facebook, Instagram, Tumblr, Reddit...
pdb
The Python Debugger
"The module pdb defines an interactive source code debugger for Python programs."
example code
estimate.py
let's use pdb
# ...
import pdb; pdb.set_trace()
# ...
the basics
let's use pdb
l (list)
list source code for the current file.
ll (longlist)
list all source code for the current function or frame.
New in version 3.2
show me where I am
let's use pdb
moving through the code
n (next)
continue until the next line in the current function
s (step)
stop at the first possible occasion
r (return)
continue until the current function returns
c (continue)
continue execution, only stop at a breakpoint
let's use pdb
$ python -m pdb you_script.py
another way to use pdb
let's use pdb
break and inspect
b (break)
set a breaking point in the source
a (args)
print the argument list of the current function
p (print) pp (pretty print)
print the evaluated expression in the current context
let's use pdb
run commands everytime
.pdbrc
let's use pdb
run commands everytime
display
display the value each time it changes
interact
start an interactive interpreter
let's use pdb
pytest + pdb
$ pytest --pdb
Thank you
pdb in action
By greenkey_loman
pdb in action
- 59