breaking out to the debugger (other than x=1/0 !)

2009-10-23 Thread bdb112
After a while programming in python, I still don't know how to break
out to the debugger other than inserting an instruction to cause an
exception.
x=1/0

In IDL one woudl write

stop,'reason for stopping...'
at which point you can inspect locals (as in pdb) and continue (but
you can't with pdb if python stopped because of an exception)

I am using ipython -pylab -pdb (python 2.5,2.6)
Yes, I realise that I could start with the debugger, and set break
points, but that can be slower and sometimes cause problems, and I
like ipython's magic features.

Also, I don't know how to stop cleanly handing control back to ipython
inside a program - e.g. after printing help text.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: breaking out to the debugger (other than x=1/0 !)

2009-10-23 Thread Diez B. Roggisch
bdb112 wrote:

 After a while programming in python, I still don't know how to break
 out to the debugger other than inserting an instruction to cause an
 exception.
 x=1/0
 
 In IDL one woudl write
 
 stop,'reason for stopping...'
 at which point you can inspect locals (as in pdb) and continue (but
 you can't with pdb if python stopped because of an exception)
 
 I am using ipython -pylab -pdb (python 2.5,2.6)
 Yes, I realise that I could start with the debugger, and set break
 points, but that can be slower and sometimes cause problems, and I
 like ipython's magic features.
 
 Also, I don't know how to stop cleanly handing control back to ipython
 inside a program - e.g. after printing help text.

I use 

 import pdb; pdb.set_trace()

Of course that can't be deleted as breakpoint - but it suits me well.

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: breaking out to the debugger (other than x=1/0 !)

2009-10-23 Thread bdb112
That's perfect - and removing the breakpoint is not an issue for me
as it is normally conditional on a debug level, which I can change
from pydb

if debuglvl3:
import pydb
pydb.set_trace()
'in XXX:  c to continue'

The text line is a useful prompt

(The example here is for pydb which works as well (and is more like
gdb).



On Oct 23, 12:07 pm, Diez B. Roggisch de...@nospam.web.de wrote:
 bdb112 wrote:
  After a while programming in python, I still don't know how to break
  out to the debugger other than inserting an instruction to cause an
  exception.
  x=1/0

  In IDL one woudl write

  stop,'reason for stopping...'
  at which point you can inspect locals (as in pdb) and continue (but
  you can't with pdb if python stopped because of an exception)

  I am using ipython -pylab -pdb (python 2.5,2.6)
  Yes, I realise that I could start with the debugger, and set break
  points, but that can be slower and sometimes cause problems, and I
  like ipython's magic features.

  Also, I don't know how to stop cleanly handing control back to ipython
  inside a program - e.g. after printing help text.

 I use

  import pdb; pdb.set_trace()

 Of course that can't be deleted as breakpoint - but it suits me well.

 Diez

-- 
http://mail.python.org/mailman/listinfo/python-list