[Tutor] Python 2.2... os.exec catch stdout

Alan Gauld alan.gauld at btinternet.com
Fri Jun 5 10:43:12 CEST 2009


"Chris Mueller" <worminater at gmail.com> wrote

> This would be simple; if I did not need to interact with my sub-program. 
> I
> currently have..
>
> pid = os.fork()
> if not pid:
>    os.execvp(program, (program,) + tuple(arguments))
> os.wait()[0]
>
> This works fine; lets me interact with "vim" fine; and return to the 
> python
> script when I am done; but I do not seem to be able to execute read 
> stdout;

If its actually vim you want to use, and by stdout you mean the text
on the screen while editing, then you have a problem in that vim
does not write to stdout! It uses curses (I think) to address the
screen directly, it does not write onto the stdout stream. (I think if you
switch to ex mode it does use stdout - but I may be wrong about that!)

If vim is just an unfortunate example then it might be possible but I think
we need to know a bit more about what exactly you are trying to do.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list