<br><br><div><span class="gmail_quote">2006/6/9, Bernard Lebel &lt;<a href="mailto:3dbernard@gmail.com">3dbernard@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I'd like to know what are the differences at the various os.popenX<br>flavors. I read the documentation and I can see they return file<br>objects..... so what can you do with these file objects? I mean, why<br>
would you need a set of file objects rather than another?<br><br>Sorry the difference is very not clear to me.<br><br><br>Thanks<br>Bernard<br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">
Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>Hello,<br><br>The common idea behind the various popen implementation is to provide the creation of 
pipes.A pipe is a flavor of a file object.A pipe serves the job to address data from a process to another,but what if sometimes you want to execute a command<br>out of the parent process on a child process?You should be able to issue the command,catch the result and even to know which way the thing has ended,at times.
<br>If you are familiar with the concept of 'streams',the &quot;input&quot;,&quot;output&quot; and &quot;error&quot; stream are the resource of communication provided by Unix to handle these tasks,respectively.Nevertheless
,at times you don't need to gather data from all the streams,but just to control two of them out of three,for example.The reason could be that of sparing system resources,time or just that you don't need or want to.popen2
,popen3 and popen4 are designed to catch exactly the streams you want to control.So:<br><br><span style="color: rgb(255, 102, 102);">popen2:</span><br>returns the file objects corresponding to the child <span style="font-weight: bold; font-style: italic;">
stdin and stdout</span><span style="font-style: italic;">;</span><br><br><span style="color: rgb(255, 102, 102);">popen3:</span><br>returns the file objects corresponding to the child <span style="font-weight: bold;"><span style="font-style: italic;">
stdin,stdout and stderr;</span><br><br></span><span style="color: rgb(255, 102, 102);">popen4:<br><span style="color: rgb(0, 0, 0);">returns the file objects corresponding to the <span style="font-weight: bold;">child stdout and stderr (
</span><span style="text-decoration: underline;">together as a single object</span>) and <span style="font-weight: bold;">stdin</span>.<br><br></span></span>The file objects,you see,are what you normally make use to manipulate data within processes.
<br>They are memory structures which assume peculiar names based on their type : Queues,Semaphores,Pipes and so on...<br>And they can persist a) in the scope of a process b) of a machine session c) on the filesystem (the strongest kind of persistence).
<br>Choosing the right one for each task a matter depending on what you want to do with them.<br>I recognize I'm not being exhaustive but hope that helps.<br><br>Cheers,<br>Ivan<br><br><br><br><br><br>