[Python-Dev] [Python-3000] Universal newlines support in Python 3.0

Russell E Owen rowen at cesmail.net
Mon Aug 13 19:46:08 CEST 2007


In article <87wsw3p5em.fsf at uwakimon.sk.tsukuba.ac.jp>,
 "Stephen J. Turnbull" <stephen at xemacs.org> wrote:

> Guido van Rossum writes:
> 
>  > However, the old universal newlines feature also set an attibute named
>  > 'newlines' on the file object to a tuple of up to three elements
>  > giving the actual line endings that were observed on the file so far
>  > (\r, \n, or \r\n). This feature is not in PEP 3116, and it is not
>  > implemented. I'm tempted to kill it. Does anyone have a use case for
>  > this?
> 
> I have run into files that intentionally have more than one newline
> convention used (mbox and Babyl mail folders, with messages received
> from various platforms).  However, most of the time multiple newline
> conventions is a sign that the file is either corrupt or isn't text.
> If so, then saving the file may corrupt it.  The newlines attribute
> could be used to check for this condition.

There is at least one Mac source code editor (SubEthaEdit) that is all 
too happy to add one kind of newline to a file that started out with a 
different line ending character. As a result I have seen a fair number 
of text files with mixed line endings. I don't see as many these days, 
though; perhaps because the current version of SubEthaEdit handles 
things a bit better. So perhaps it won't matter much for Python 3000.

-- Russell



More information about the Python-Dev mailing list