line break confusion

Michael Mell mike at
Sat Feb 16 03:37:57 CET 2002

Using Python 2.2 running on any arbitrary OS (Linux, Win, Mac), I want
    1) read several files having an arbitrary mix of line break types
(Linux, Win, Mac)
    2) then standardize the breaks of each of the files to a single type
    3) then concatenate them all into a string for writing.

Linux and Mac:
    I have not found the magic string which represents the Windows line
break on Linux or Mac. Neither '\r\n', nor '\n\r' works.
    It seems that RETURN and NEWLINE are swapped: an '\r' creates Linux
breaks, an '\n' creates Mac breaks.

In the string module, whitespace = ' \t\n\r\v\f' (5 characters here).
Yet, when I run this:
>>> import string
>>> for c in string.whitespace:
>>>     print '.'+ c + '.'

I get 7 results.
What's going on here?


mike at
llemekim         YahooIM
415.455.8812     voice
419.735.1167     fax

More information about the Python-list mailing list