[Python-3000] sys.stdin and sys.stdout with textfile
"Martin v. Löwis"
martin at v.loewis.de
Tue Oct 3 12:34:29 CEST 2006
Greg Ewing schrieb:
>> All sorts of things are different when reading stdin vs. opening a
>> filename. e.g. stdin may be a pipe.
> Which suggests that if anything is going to try
> to guess the encoding, it would be better for it
> to start reading from the actual stream you're
> going to use and buffer the result, rather than
> rely on being able to open it separately.
As Guido says: *all* sorts of things are different. When
stdin is a terminal, there are separate API functions which
we should use to determine the terminal's encoding. This
does neither require to read data from a stream, nor
to open a file. If we read data from a pipe, it is probably
most natural to assume that the system code page/locale
encoding is used for these data.
More information about the Python-3000