[IPython-user] debugging question

Fernando Perez fperez.net at gmail.com
Mon Jan 1 17:12:25 CST 2007


On 12/31/06, Ville M. Vainio <vivainio at gmail.com> wrote:
> On 12/31/06, belinda thom <bthom at cs.hmc.edu> wrote:
>
> > Is it possible to use run -d (or some debugging equivalent) to run a
> > particular function or method from w/in a module?
>
> Not currently, at least.

I just spent a bit of time with the pdb/bdb codes, and it's
unfortunately not well set up to easily support this.  The do_break()
command only accepts either a filename:linenumber pair, or a function
name but which must evaluate in an already set up execution context
where the file has already been loaded into memory and the debugger is
up and running.

So implementing this at the %run or %prun level would require parsing
the input file to find a suitable definition line number.  This is not
trivial without executing the file first, since it's possible to have
things like

if os.name=='foo':
  def bar(): a()
else:
  def bar(): b()

and by simple text analysis one can't know which is the correct
definition line number.

Regards,

f


More information about the IPython-user mailing list