On Sat, Feb 06, 2010 at 11:27:50AM +0100, Pierre Raybaut wrote:
> > Why not? I use Ipython on OS-X all the time, and it is fabulous, really 
> > fabulous.

> >> >  Also, I would rather stick with IDLE.  It is the perfect IDE for
> >> >  non-CS students who shouldn't be spending their time on the
> >> >  complexities of a plotting package.

> > Spyder:
> > http://packages.python.org/spyder/
> > Looks really promising, but I don't think they've got OS-X packages yet.

> > [snip]

I'd like to pitch here the reason why I think there is a huge gain in
using IPython, because I think that not everybody realizes this.

For me, the killing feature is '%debug'. It enables you to drop in the
debugger post mortem. That means that if there is an exception raised
during a calculation, I can drop right where the exception occurred and
inspect the variables there. I can for instance check if a numpy array
has NaNs, and if so where they are, or if a matrix that is supposed to be
symmetric really is. I can also go up the call stack, and see what the
variables are at each level of function calls. Here is a trivial example:

In [1]: def f(x, y=0):
   ...:     z = x+y
   ...:     return 1/z
   ...: 

In [2]: f(0)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call
last)

/home/varoquau/<ipython console> in <module>()

/home/varoquau/<ipython console> in f(x, y)

ZeroDivisionError: integer division or modulo by zero

In [3]: %debug
> <ipython console>(3)f()

ipdb> print x
0
ipdb> print y
0
ipdb> print z
0
ipdb> 

Jose Unpinco has written a nice video introducing these features:
http://showmedo.com/videotutorials/video?name=7200060&fromSeriesID=720

When you start having a somewhat complex set of functions that call
each other, or when you are getting failures with somebody else's code,
this is priceless. This is so useful that to debug some code that, when I
am trying to understand why some code is not working the way it should
be, I will purposely add an exception, to be able to introspect the code.
Granted, adding pdb.set_trace() will work without IPython[*], but I find
it very useful.

I am to the point where the post-mortem debugging of IPython may be the
killing feature of Python that I lack with every other work flow. The
reason being that I develop data processing code, and that I am always
experiment and trying to implement new algorithms. As a result, my code
is seldom mature, and I often spend time tracking down where bugs lie.
Also, running my various processing steps take a while. This is why I
rely a lot on post-mortem: I find bugs after minutes or hours of number
crunching, and I want to be as efficient as possible. Post-portem enables
me not to restart the script that crashed.

My 2 cents,

Gaƫl

[*] It will not work in Spyder as it is quite challenging to have these
features requiring user terminal interaction in a GUI.


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to