Interpreter fussy about line endings?

Greg Ewing greg.ewing at compaq.com
Wed May 5 19:04:07 EDT 1999


Tim Peters wrote:
> 
> Text files aren't portable in or out of the Python world.

I understand that about text files in general, but
I had expected the interpreter to be more lenient
about what it expects as source text.

Sorry if my comment came across as a whinge - it wasn't
meant to be. I was genuinely surprised that the parser
didn't just treat '\r' characters as whitespace. It
seemed as though a test had been inserted specifically
to make source code from another platform break, and
I was wondering why this had been done. Hence my
question:

>> Is it meant to be like this?

This was a serious question: was it *designed* to
do this, and if so, why? All it seemed to do is make
something that would otherwise work fail.

Thinking about it more, I can see that it could be
a bit tricky dealing with all combinations of
CR, LF and CRLF correctly without prior knowledge of
what platform the source came from.

Guido reports that there are thoughts of doing
something about this in a future release. That would
be good. Since Python is meant to be cross-platform, 
and for most intents and purposes the source code *is*
the program, it would make sense to have a source
code format that could be relied upon to work on
any Python interpreter!

Greg




More information about the Python-list mailing list