start pdb from within a script:
import pdb;pdb.set_trace()
start pdb from the commandline:
python -m pdb <file.py>
h
(elp) print available commands.
h
(elp) command print help about command.
q
(quit) quit debugger.
p
(rint) expr print the value of expr.
pp
expr pretty-print the value of expr.
w
(here) print current position (including stack trace).
l
(ist) list 11 lines of code around the current line.
l
(ist) first, last list from first to last line number.
a
(rgs) print the args of the current function.
<ENTER>
repeat the last command.
n
(ext) execute the current statement (step over).
s
(tep) execute and step into function.
r
(eturn) continue execution until the current function returns.
c
(ontinue) continue execution until a breakpoint is encountered.
u
(p) move one level up in the stack trace.
credits : https://github.com/nblock/pdb-cheatsheet