Detecting line endings

Alex Martelli aleaxit at yahoo.com
Mon Feb 6 23:38:06 EST 2006


Fuzzyman <fuzzyman at gmail.com> wrote:

> Hello all,
> 
> I'm trying to detect line endings used in text files. I *might* be
> decoding the files into unicode first (which may be encoded using

Open the file with 'rU' mode, and check the file object's newline
attribute.

> My worry is that if '\n' *doesn't* signify a line break on the Mac,

It does, since a few years, since MacOSX is version of Unix to all
practical intents and purposes.


Alex



More information about the Python-list mailing list