At 12:04 PM 9/29/2007 -0700, Gregory P. Smith wrote:
>On 9/29/07, Jeffrey Yasskin ><<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote: >On 9/29/07, Phillip J. Eby ><<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote: > > At 07:33 AM 9/29/2007 -0700, Guido van Rossum wrote: > > >Until just before 3.0a1, they were unequal. We decided to raise > > >TypeError because we noticed many bugs in code that was doing things > > >like > > > > > > data = f.read(4096) > > > if data == "": break > > > > Thought experiment: what if read() always returned strings, and to > > read bytes, you had to use something like 'f.readinto(ob, 4096)', > > where 'ob' is a mutable bytes instance or memory view? > > >Using what encoding? read() should raise an exception on a file >opened as binary in that case. Yes, that's what I meant -- the availability of read() and readinto() would be mutually exclusive. > And instead of readinto() how about readbytes() that just returns > bytes and raises an exception on non-binary mode files. Sure. > (readinto for buffers is a good idea and i think we should have > it but that idea could be taken further to allow for even more > scattered IO into a mutable buffer; thats another discussion and > should be a PEP of its own) Fair enough, although readbytes() can be implemented in terms of readinto(), while the reverse isn't the case. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com