On Tue, 22 Jul 2008, Cameron Simpson 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?

I think read(0) should be a no-op, just like it is in libc.  This lets
you write 'read(bytes)' without worrying about checking bytes, and
also lets you silently stop reading when you have no more space, like
in the following:

buf = f.read(max(bytes_left, page_size))
while buf:
  process(buf)  # updates bytes_left
  buf = f.read(max(bytes_left, page_size))

-- 
Cheers,
Leif
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to