[Python-Dev] fileobj.read(float): warning or error?
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Sep 3 02:49:17 CEST 2008
Jesus Cea wrote:
> How do you differenciate between that empty string (when doing
> "read(0)"), from EOF (that is signaled by an empty string)?.
If you need to be able to make that distinction, then
you have to be careful not to try to read 0 bytes.
Personally I've never come across a situation where
allowing read(0) to occur would have simplified the
code. In the usual keep-reading-until-we've-got-the-
required-number-of-bytes scenario, you're checking
for 0 bytes left to read in order to tell when to
stop.
--
Greg
More information about the Python-Dev
mailing list