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

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Aug 16 04:01:04 CEST 2007


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.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-3000 mailing list