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

Tony Lownds tony at PageDNA.com
Wed Aug 15 20:27:45 CEST 2007


On Aug 14, 2007, at 9:56 PM, Guido van Rossum wrote:

> I thought some more about the universal newlines situation, and I
> think I can handle all the use cases with a single 'newline'
> parameter. The use cases are:
>
> (A) input use cases:
>
> (1) newline=None: input with default universal newlines mode; lines
> may end in \r, \n, or \r\n, and these are translated to \n.
>
> (2) newline='': input with untranslated universal newlines mode; lines
> may end in \r, \n, or \r\n, and these are returned untranslated.
>
> (3) newline='\r', newline='\n', newline='\r\n': input lines must end
> with the given character(s), and these are translated to \n.
>
> (B) output use cases:
>
> (1) newline=None: every \n written is translated to os.linesep.
>
> (2) newline='': no translation takes place.
>
> (3) newline='\r', newline='\n', newline='\r\n': every \n written is
> translated to the value of newline.
>

These make a lot of sense to me. I'm working on test cases / cleanup,
but I have a patch that implements the behavior above. And the
newlines attribute.

Thanks
-Tony




More information about the Python-3000 mailing list