[IPython-dev] [newbie] stepping through code using the 1/0 trick?

Robert Kern robert.kern at gmail.com
Wed Jan 6 12:27:39 EST 2010


On 2010-01-06 11:16 AM, Lara Michaels wrote:
> hi everyone,
>
> I have watched the excellent video tutorial on debugging with ipython,
> but I cannot get a hang of how to use it to step through code. I am
> using the trick of inserting 1/0 in my code where I want the debugger to
> come up.
>
> Then I get pdb (as expected), but if I try the n(ext) or s(tep) commands
> I am immediately dropped back onto the "normal" ipython shell.

You cannot step past an exception.

> Is there a way to step through code without importing pdb and using
> set_trace()?

Why not use set_trace() if you are already inserting exceptions using 1/0?

   import pdb;pdb.set_trace()

Use your editor's macro facilities to make this easy.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the IPython-dev mailing list