Serge Orlov wrote:
> 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)

Weird... I never knew this, although I had noticed-in-passing that 
hitting ^Z to exit the interpreter didn't always work as intended.  Nice 
to have an explanation why.

On a related note though: EOF _is_ recognized in mid-line if you are 
just reading from a file (in text mode, obviously, not binary mode).  I 
wonder what freakish design decisions led to that situation...

-Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to