One thing that could be also confusing is that (as far as I understand) 
stdin and stdout are actually the same file if your process is attached to 
a pseudo terminal. In that case, stdin is opened as read, while stdout is 
opened as write. (Internally, often os.dup2 is used by the parent process 
to copy the file descriptor from '0' to '1' and '2' before running exec, 
making them identical. See pexpect for instance.) But if you open a 
subprocess, it's possible to use pipes, and I think in that case, they are 
really different file descriptors.

Further.
StreamReader and StreamWriter are often used in pairs. In Python2.7.3, you 
can do create a bidirectional pipe on stdin/out as follows:

>>> import os
>>> fd = os.fdopen(0, 'r+')
>>> 

Now 'fd' supports both read and write operations.
However, in Python 3.3, you can't create such an object:

>>> import os
>>> os.fdopen(0, 'r+')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.3/os.py", line 1032, in fdopen
    return io.open(fd, *args, **kwargs)
io.UnsupportedOperation: File or stream is not seekable.
>>> 

I think that could be a bug in Python 3, but I'm not sure. 
 

Reply via email to