[IPython-user] [Python-Dev] a quit that actually quits

Ville Vainio vivainio at gmail.com
Tue Jan 3 07:04:00 CST 2006


On 1/3/06, Walter Dörwald <walter at livinglogic.de> wrote:

> > BTW, is the curses even necessary for this task? Why not just dump the
> > stuff directly to stdout?
>
> That's another option of course. But moving backwards in the output is
> impossible (or at least ackward) in this version.

I think old versions of "more" did this tolerably... it doesn't look
good on screen (because it scrolls down while you are actually moving
up) but the ease of implementation (and fast redraw these days) eases
the pain a bit.

> Well if you want to give the user the option to go back to the first
> object, you'd have to tee() the iterator before you fetch any objects
> from it, which mean that you'd keep a list of all objects in memory
> anyway. And when you do that, you can go straight to a list without
> using itertools.tee().

Not quite, you'll still fetch the upcoming items "lazily", so that you
don't need to prefetch 1000000 lines from a long generator or choke on
an infinite one...

> But how would %page recognise which columns/attributes to display?
> Furthermore I'd like to be able to manipulate this generator (filtering,
> sorting, etc.). As an example take a look at
>
>     http://www.livinglogic.de/Python/sh.py

Yes, the filter idea is certainly interesting and useful.

> This implements env (as a wrapper for os.environ) and pwd (as a wrapper
> for the pwd module (if you're on Linux)). Just do a "from sh import *"

The special case for es.environ might be a bit too specific - why not
just do general wrapper for dicts and always use "key" and "val" for
field names? Then you could do

tabulatedict(os.environ) / contains(key='PY') / sort(val=True) / WalterPager

--
Ville Vainio    http://tinyurl.com/2prnb
  Can't you see the world is burning
  Can't you feel its Fire burning
  Don't you know we all are burning
  The Fire of Life       -- R.N.Taylor / Changes




More information about the IPython-user mailing list