[Python-3000] Draft PEP for New IO system

Jean-Paul Calderone exarkun at divmod.com
Wed Feb 28 15:10:46 CET 2007


On Wed, 28 Feb 2007 07:39:33 -0600, Daniel Stutzbach <daniel at stutzbachenterprises.com> wrote:
>
> [snip]
>
>> - Should read()/readinto() raise EOFError?
>
>On EOF, they return a length-0 object or 0 instead.  If the user tries
>to read again *after* hitting EOF, then an EOFError is raised.
>

What is the motivation for having two different ways to signal EOF?  How
is this case handled?

   >>> f = file('name', 'w')
   >>> g = file('name', 'r')
   >>> g.read(10)
   ''
   >>> f.write('bytes')
   >>> f.flush()
   >>> g.read(10)
   'bytes'
   >>>

Jean-Paul


More information about the Python-3000 mailing list