[IPython-dev] A cool python recipe - maybe useful for ipython

Fernando Perez fperez.net at gmail.com
Sun May 14 21:07:16 EDT 2006

Hi Gary,

[I'm cc-ing ipython-dev in case anyone wants to pick this up and
submit a patch ]

On 5/13/06, Gary Ruben <gruben at bigpond.net.au> wrote:

> I just thought you might like this cookbook recipe. I didn't know such
> things were so simple and I thought ipython might benefit from it.
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/409000

It does look nice, unfortunately in its current form it is something
that you must use in all of your classes, and it causes a lot of
overhead (__getattr__ is probably the most often fired method on an
object, so you really don't want it to be any slower than it needs to

It would be a lot more useful if this were something that ipython
could do for you, regardless of whether the underlying object had
implemented it.

If some enterprising soul wants a stab at this, it can be initially
(for testing) done as a custom exception handler, which fires on all
AttributeErrors.  It can then implement this kind of introspection
/after/ the error has fired, without introducing any overhead at

Note that doing this isn't totally trivial: you'll have the exception
and the stack, but identifying the offending object is something which
I'm not really sure how to do.

But thanks for the pointer, it's a neat recipe!



More information about the IPython-dev mailing list