[Python-3000] Proposed new language for newline parameter to TextIOBase

Adam Olsen rhamph at gmail.com
Thu Aug 16 04:41:36 CEST 2007


On 8/15/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Adam Olsen wrote:
> > On 8/14/07, Guido van Rossum <guido at python.org> wrote:
>  >
> > > (2) newline='': input with untranslated universal newlines mode; lines
> > > may end in \r, \n, or \r\n, and these are returned untranslated.
> >
> > Caveat: this mode cannot be supported by sockets.  When reading a lone
> > \r you need to peek ahead to ensure the next character is not a \n,
> > but for sockets that may block indefinitely.
>
> You could return as soon as you see the '\r', with
> a flag set indicating that if the next character
> that comes in is '\n' it should be ignored.

That would be the *other* universal newlines mode. ;)

(Once you're already modifying the output, you might as well convert
everything to '\n'.)

-- 
Adam Olsen, aka Rhamphoryncus


More information about the Python-3000 mailing list