[IPython-user] IPython 0.7.1 is out.
walter at livinglogic.de
Tue Jan 24 08:52:58 CST 2006
Ville Vainio wrote:
> On 1/24/06, Walter Dörwald <walter at livinglogic.de> wrote:
>> Sounds great! Can you show an example for installing a display hook? Is
>> it OK to just use print in the hook, or do I have to use IPython's
>> output facility?
> Too busy to verify right now, but the hook name is "results_display".
> hooks.py has the default implementation, you can do
> ipapi.set_hook("results_display",my_display_hook) to set your own.
Actually it's "result_display", here's what I'm using now:
if hasattr(__builtin__, "__IPYTHON__"):
from IPython import ipapi, hooks
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):
Is hasattr(__builtin__, "__IPYTHON__") the correct way to determine if
I'm running under IPython?
>> BTW, the TryNext exception should be available in the IPython.ipapi module.
> I thought so too, I'll move TryNext to ipapi.
>> Another enhancement request: It would be great if the return value of
>> the displayhook would be assigned to the _ variable (instead of the
>> original object). This way e.g. a curses based browser could be used to
>> select an object from a list, pressing a key returns to the IPython
>> shell with the picked objects as _.
> I will explore this, sounds good.
> BTW, I figured I'll put your generator pipe utilities to Extensions
> dir, once you get the displayhooks & all properly set up.
I'm making good progress on the curses-based browser (I find programming
curses actually fun). Here are a few screenshots:
Browsing the result of:
isort("len(name),name.lower()") | iwide
(I've switched to | as the piping character, as this makes it possible
to use + for chaining, i.e. you can use ipwd + igrp to browse a combined
list of the /etc/passwd and /etc/groups entries.
You can browse anything that's iterable, the following gives you a
simple text viewer:
open("/usr/local/lib/python2.4/site-packages/IPython/ipapi.py") | ibrowse
It's possible to browse database content too:
>>> from ll import orasql
>>> db = orasql.connect(...)
>>> c = db.cursor()
>>> c.execute("select * from buildlog_select order by r_id desc,
>>> c | ibrowse
More information about the IPython-user