A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-September/082147.html below:

[Python-Dev] fileobj.read(float): warning or error?

[Python-Dev] fileobj.read(float): warning or error? [Python-Dev] fileobj.read(float): warning or error?Isaac Morland ijmorlan at cs.uwaterloo.ca
Tue Sep 2 19:17:02 CEST 2008
On Tue, 2 Sep 2008, Jesus Cea wrote:

>> Indeed. read(0) is quite often generated as an edge case when one is
>> computing buffer sizes, and returning an empty string is most
>> definitely the right thing to do here (otherwise some application code
>> becomes more complex by having to avoid calling read(0) at all).
>
> How do you differenciate between that empty string (when doing
> "read(0)"), from EOF (that is signaled by an empty string)?.

Why would you expect a difference between reading 0 bytes at EOF and 
reading 0 bytes anywhere else?  If you read(4) when at offset 996 in a 
1000-byte file I doubt you expect any special notification that you are 
now at EOF.

The Unix read() system call doesn't treat EOF as special other than it 
won't return bytes from "beyond" EOF and therefore even when reading a 
regular file could return fewer (including 0) bytes than asked for in the 
call.

Isaac Morland			CSCF Web Guru
DC 2554C, x36650		WWW Software Specialist
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4