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

Jesus Cea jcea at jcea.es
Tue Sep 2 19:05:46 CEST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Guido van Rossum wrote:
> On Mon, Jul 21, 2008 at 10:37 PM, Cameron Simpson <cs at zip.com.au> wrote:
>> Leaving aside the 0.2 => 0 converstion, shouldn't read() raise an
>> exception if asked for < 1 bytes? Or is there a legitimate use for read(0)
>> with which I was not previously aware?
> 
> 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)?.

- --
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea at jcea.es - http://www.jcea.es/     _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea at jabber.org         _/_/    _/_/          _/_/_/_/_/
.                              _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBSL1yZplgi5GaxT1NAQJdTAP7B4GaeBRFg1A6PibmH+2cmJs3AIO2qWrx
xfgRO1QVF4OnxGWIKTTbKWX4whBY/zA3UUs35XMSRUROlxPR1dCNIvlaQb+rCuO6
AL0IkE5Fe6iN+VlS9UqarUla9vGhrqD9BxMZmDisIu4uKJi7c3ChlGKuatk16RBQ
BosUJe3VjNM=
=GkbX
-----END PGP SIGNATURE-----


More information about the Python-Dev mailing list