> I'd like to know what are the differences at the various os.popenX
> flavors. I read the documentation and I can see they return file
> objects..... so what can you do with these file objects? I mean, why
> would you need a set of file objects rather than another?

My OS topic covers some of the popen variants with explanation.
It might help.

Here are the most relevant two paragraphs:

--------------
In fact there are several variations of the popen command called 
popen, popen2, popen3 and popen4. The numbers refer to the various 
data stream combinations that are made available. The standard data 
streams were described in a sidebar in the Talking to the User topic. 
The basic version of popen simply creates a single data stream where 
all input/output is sent/received depending on a mode parameter passed 
to the function. In essence it tries to make executing a command look 
like using a file object.

By contrast, popen2 offers two streams, one for standard output and 
another for standard input, so we can send data to the process and 
read the output without closing the process. popen3 provides stderr 
access in addition to stdin/stdout. Finally there is popen4 that 
combines stderr and stdout into a single stream which appears very 
like normal console output. In Python 2.4 all of these popen calls 
have been superseded by a new Popen class found in a new subprocess 
module which we will look at later. For now we will only look at the 
standard os.popen() function, the others I will leave as a research 
exercise!

---------------

Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to