Logged In: YES
user_id=593130
You (understandably) confused two nearly identical but
different functions with two different return conventions
(reversed from each other).
>>> from os import popen4
>>> popen4
<built-in function popen4>
>>> popen2.popen4
<function popen4 at 0x00898768>
Module-popen2.html talks about popen2.popen4 and not
os.popen4.
Module popen2 has 3 functions popen2/3/4 which
consistently return the read and write pipes in that order
(well, popen3 is more complicated, but never mind).
The os module also has functions of the same name but
with reversed return order -- in/out -- as documented:
"This functionality is also available in the popen2 module using
functions of the same names, but the return values of those
functions have a different order."
Why ther reversal? No idea.
The same hint/warning currently does NOT appear in the
popen2 doc nor in its doc string (as accessed via help()) and
I agree it should be.
Suggestion to doc fixer: in Lib Ref 6.8 popen2, end of 4th
paragraph, ending in " or the equivalent functions in the os
module." --
Add "(with reversed return tuples)" before the period.
Without this caveat, they are not really equivalent, as Chen
tripped over.
|