[Python-Dev] [python] Re: New lines, carriage returns, and Windows

Terry Reedy tjreedy at udel.edu
Sat Sep 29 23:53:49 CEST 2007


"Michael Foord" <fuzzyman at voidspace.org.uk> wrote in message 
news:46FE9B09.8000800 at voidspace.org.uk...
| Terry Reedy wrote:
| > There are two normal ways for internal Python text to have \r\n:
| > 1. Read from a file with \r\r\n.  Then \r\r\n is correct output (on the
| > same platform).
| > 2. Intentially put there by a programmer.  If s/he also chooses default 
\n
| > translation on output, \r<translation of \n> is correct.
| >
| Actually, I usually get these strings from Windows UI components. A file
| containing '\r\n' is read in with '\r\n' being translated to '\n'. New
| user input is added containing '\r\n' line endings. The file is written
| out and now contains a mix of '\r\n' and '\r\r\n'.

I covered this in the part you snipped:

"2. Other special situations, which can be handled by disabling, 
overriding,
and layering the defaults.  This seems enough flexibility to me."

While mixing input like this may seem 'normal' to you, I believe it is 
'special'
considering the total Python community.  I can think of at least 4 decent 
solutions, depending on the details of the input and what you do with it.

tjr





More information about the Python-Dev mailing list