Cursed newlines and readline()

Edward K. Ream edream at tds.net
Thu Sep 12 20:59:14 CEST 2002


According to one of Leo's Linux users, the Python's readline() routine on
Linux delivers "\r\n" line end strings verbatim, while the windows versions
force the string to use the Unix convention of using only "\n". This seems
unfortunate.  Is there a justification for it?  If not, I would like to
suggest that readline() work the same on all platforms and that it deliver
only "\n" as a line terminator.

This is an example of what I have come to call the "cursed newline" problem,
a problem that seems trivial, and in fact has caused me, by far, the most
grief as a programmer trying to write cross-platform software.  BTW, TK
handles this problem superbly, so well that one might not even suspect that
it is a problem.

Any comments?

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edream at tds.net
Leo: Literate Editor with Outlines
Leo: http://personalpages.tds.net/~edream/front.html
--------------------------------------------------------------------






More information about the Python-list mailing list