[IPython-user] [Python-Dev] a quit that actually quits
walter at livinglogic.de
Tue Jan 3 05:57:05 CST 2006
Ville Vainio wrote:
> On 1/3/06, Walter Dörwald <walter at livinglogic.de> wrote:
>>For Windows there could probably be a "real" GUI output. (But I don't
>>know if it's possible for a shell program to open windows).
> It is, I think it's even the typical scenario in UI example programs.
> Of course the GUI output would be usable in Linux as well (with any
> sensible non-MFC toolkit), and it would kinda make the curses browsing
> component almost redundant.
Not if you're using python over an ssh connection (which I do almost all
> 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.
Nevertheless having plain output or curses output or real GUI output
should all be possible with this system.
> If you want to go back you would need to
> "itertools.tee" the generator but there is no way around that
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
> I guess what could be trivially done already is to enhance %page to
> recognize a generator and start iteratively dumping it, possibly
> replacing the original object with itertools.tee:d version of the
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
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 *"
to get the objects (note that this uses it's own displayhook). This
doesn't use curses yet, but does a plain dump to sys.stdout. Anyway
typing "env" or "pwd" will give you a tabular view of your environment
variables or your pwd entries. And you can do stuff like:
name |value |
name|passwd|uid|gid|gecos|dir |shell |
root|x |0 |0 |root |/root|/bin/bash|
More information about the IPython-user