continue out of a loop in pdb

R. Bernstein rocky at
Wed May 24 05:09:29 CEST 2006

"Diez B. Roggisch" <deets at> writes:

> > the code works with no problem, I am playing around with the pdb, i.e
> > ****************
> > from pdb import *
> > set_trace() for i in range(1,500000):
> >     print i
> > print "tired of this"
> > print "I am out"
> > ****************
> > fred at debian:~/python/practic$ python
> >> /home/fred/python/practic/
> > -> for i in range(1,500000):
> > (Pdb) n
> >> /home/fred/python/practic/
> > -> print i
> > (Pdb) n
> > 1
> >> /home/fred/python/practic/
> > -> for i in range(1,500000):
> > (Pdb) b 6
> > Breakpoint 1 at /home/fred/python/practic/
> > (Pdb) c
> >> /home/fred/python/practic/
> > -> print i <<<< I expected (print "tired of this")
> > (Pdb)
> In TFM it says that set_trace() puts a breakpoint to the current
> frame. I admit that I also wouldn't read that as "each and every
> instruction in this very frame", but that is what essentially
> happens. I think the docs could need some enhancement here. Try
> debugging a called function, there things will work as expected.

Let me try to explain my understanding here. set_trace() merely tells
the Python interpreter to call the debugger dispatcher after the call
to set_trace() finishes. In effect this is at the next statement of
your program because the caller frame here is always the "set_trace()"
call you put in your program. Okay, so now we've called this "debugger
dispatcher" thing and what does that do? Well, it accepts commands
from you, like "next" or "step" or "continue". .

In the case above, Python was told to make that set-trace call 500000

But yes, I agree the wording in in the pdb (and pydb) manuals are
written too much from view of someone writing a debugger rather than
someone using it.  If you or someone else wantsto make a suggestion as
to how to make the description of set_trace() more user friendly (and I
don't think the above explanation succeeds), I'll put it in the next
release of pydb ( which probably
will be in the not-too distant future.

More information about the Python-list mailing list