[Python-3000] Proposed new language for newline parameter to TextIOBase (original) (raw)

Guido van Rossum guido at python.org
Sat Sep 8 16:27:17 CEST 2007


On 9/8/07, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:

Dnia 14-08-2007, Wt o godzinie 21:56 -0700, Guido van Rossum napisaƂ(a):

> (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. What is the difference between '' and '\n'?

None on output.

On input, "\n" disables universal newline mode altogether ("\r" doesn't end a line), while "" enables universal newlines for determining the line ending, but disables the translation part, meaning you will get lines ending in "\r", "\r\n", or "\n" depending on what's in the input. The default UN mode with translation is easier for most apps (since it guarantees that lines end in \n like most apps expect), but the UN mode without translation is handy if you want to copy the file faithfully (apart from specific edits).

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-3000 mailing list