mode parameter in popen2-4

T

Tobiah

In the popen docs, a file like object is returned,
and may be read to or written to depending on the
'mode' parameter ('r', or 'w').

Why is the mode parameter needed for popen2 and greater,
when both a stdin and stdout object is returned? One
wouldn't want to 'append' to a stream.... is it because
binary mode can still be turned on and off this way?

Thanks,

Tobiah
 
G

Gabriel Genellina

In the popen docs, a file like object is returned,
and may be read to or written to depending on the
'mode' parameter ('r', or 'w').

Why is the mode parameter needed for popen2 and greater,
when both a stdin and stdout object is returned? One
wouldn't want to 'append' to a stream.... is it because
binary mode can still be turned on and off this way?

Exactly. For popen[234] the mode parameter can be either 't' or 'b',
not 'r' or 'w' - which you could have learned easily reading the
documentation at <http://docs.python.org/lib/os-newstreams.html> and
<http://docs.python.org/lib/module-popen2.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,198
Latest member
JaimieWan8

Latest Threads

Top