Detecting line endings
Fuzzyman
fuzzyman at gmail.com
Tue Feb 7 04:27:30 EST 2006
Alex Martelli wrote:
> 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.
>
Ha, so long as it works with Python 2.2, that makes things a bit
easier.
Rats, I liked that snippet of code (I'm a great fan of list
comprehensions). :-)
> > 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.
>
I wondered if that might be the case. I think I've worried about this
more than enough now.
Thanks
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
>
> Alex
More information about the Python-list
mailing list