[IPython-user] IPython 0.7.1 is out.

Fernando Perez Fernando.Perez at colorado.edu
Tue Jan 24 11:35:19 CST 2006


Walter Dörwald wrote:

> Actually it's "result_display", here's what I'm using now:
> 
> import __builtin__
> if hasattr(__builtin__, "__IPYTHON__"):
>     from IPython import ipapi, hooks
> 
>     @ipapi.ashook("result_display")
>     def displayhook(self, obj):
>        if isinstance(obj, type) and issubclass(obj, Table):
>           obj = obj()
>        if isinstance(obj, Table):
>           obj = obj | defaultdisplay
>        if isinstance(obj, Display):
>           return obj.display()
>        else:
>           raise hooks.TryNext

Ville is already aware of this, but just so you can make his work a little 
easier, please use non-decorator syntax on all code that we can include in 
shipping IPython.  We still need to support python 2.3 users, and decorators 
can be written (admittedly less elegantly) as regular function calls.

> Is hasattr(__builtin__, "__IPYTHON__") the correct way to determine if 
> I'm running under IPython?

Yup.  Not the nicest, but it works.  This can also be written as:

try:
   __IPYTHON__
   ipython_on = True
except NameError:
   ipython_on = False

It's pretty much up to you.  Ville may have added a wrapper to this in the new 
api module, I'm not sure.

> I'm making good progress on the curses-based browser (I find programming 
> curses actually fun). Here are a few screenshots:

Nice.  I look forward to playing with this, now that I don't have to write it :)

Cheers,

f




More information about the IPython-user mailing list