[IPython-user] [Python-Dev] a quit that actually quits
Fernando Perez
Fernando.Perez at colorado.edu
Wed Jan 4 01:41:20 CST 2006
Walter Dörwald wrote:
> This can be done with the following filter that transforms a dictionary
> (well anything that has a iteritems()) into a browseable filter:
>
> class tabulatedict(Filter):
> def operate(self, iterator):
> class dictentry(Object):
> __shattrs__ = ("key", "val")
>
> def __init__(self, key, val):
> self.key = key
> self.val = val
>
> for item in iterator.iteritems():
> yield dictentry(*item)
>
> With this you can do:
>
> >>> os.environ / tabulatedict() / contains(key="HOME") / sort(key=False)
> key |val |
> HOME |/var/home/walter |
> JAVA_HOME |/opt/j2sdk1.4.1_02 |
> ORACLE_HOME|/oracle/Client |
> TOMCAT_HOME|/opt/jakarta-tomcat|
Neat! This is a nice hack, I've saved it and will play with it later. Ville,
who's one of our resident ipython-as-shell diehards, might even 'ipythonize' it :)
Cheers,
f
More information about the IPython-user
mailing list