It's possible to use both pdb or ipdb (pdb with ipython support!).
During code execution:
import pdb; pdb.set_trace()
The main commands here are (see help for more suggestions):
l(ist) [first[, last]]
a(rgs): show current input args
! <here goes the code>, otherwise pdb could interpretate as self command
s(tep) inside function
run unt(il) current line is passed (like for loops)
to function return
c(ontinue) to the end
- u(p), d(own) and w(here).
$ python -m pdb looping.py