Detecting line endings

Fuzzyman fuzzyman at gmail.com
Mon Feb 6 10:26:44 EST 2006


Sybren Stuvel wrote:
> Fuzzyman enlightened us with:
> > My worry is that if '\n' *doesn't* signify a line break on the Mac,
> > then it may exist in the body of the text - and trigger ``ending =
> > '\n'`` prematurely ?
>
> I'd count the number of occurences of '\r\n', '\n' without a preceding
> '\r' and '\r' without following '\n', and let the majority decide.
>

Sounds reasonable, edge cases for small files be damned. :-)

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

> Sybren
> --
> The problem with the world is stupidity. Not saying there should be a
> capital punishment for stupidity, but why don't we just take the
> safety labels off of everything and let the problem solve itself?
>                                              Frank Zappa




More information about the Python-list mailing list