Can't detect EOF from stdin on windows console
Serge Orlov
Serge.Orlov at gmail.com
Mon Apr 3 11:12:40 EDT 2006
Dmitry Anikin wrote:
> I want to read stdin in chunks of fixed size until EOF
> I want to be able (also) to supply data interactively in console
> window and then to hit Ctrl+Z when finished
[snip fighting with windows]
> Read at most size bytes from the file (less if the read hits EOF before obtaining size bytes).
> According to that, stdin.read(3), when supplied with "12^Z" should return immediately
> with two-character string instead of waiting for third character after EOF.
On windows EOF is recognized only in the beginning of a line. That is
how almost all console applications work on windows. So you have to use
either .readline() method or .read(1)
More information about the Python-list
mailing list