greenkey
http://loman.it
Twitter: @greenkey
GitHub: greenkey
LinkedIn: in/lorenzomele
Google: lorenzo.mele
Facebook, Instagram, Tumblr, Reddit...
The Python Debugger
"The module pdb defines an interactive source code debugger for Python programs."
estimate.py
# ...
import pdb; pdb.set_trace()
# ...
the basics
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
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
$ python -m pdb you_script.py
another way to 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
run commands everytime
.pdbrc
run commands everytime
display
display the value each time it changes
interact
start an interactive interpreter
pytest + pdb
$ pytest --pdb