Greg> Maybe there should be a universal newlines mode defined for output
    Greg> as well as input, which translates any of "\r", "\n" or "\r\n"
    Greg> into the platform line ending.

    Skip> I'd be open to such a change.  Principle of least surprise?

    Guido> The symmetry isn't as strong as you suggest, but I agree it would
    Guido> be a useful feature. Would you mind filing a Py3k feature request
    Guido> so we don't forget?

    Guido> A proposal for an API given the existing newlines=... parameter
    Guido> (described in detail in PEP 3116) would be even better.

I've been thinking about this some more (in lieu of actually writing up any
sort of proposal ;-) and I'm not so sure it would be all that useful.  If
you've opened a file in text mode you should only be writing newlines as
'\n' anyway.  If you want to translate a text file imported from another
system to use the current system's line ending just open both the input and
output files in text mode.

With universal newlines mode for output, should writing '\r\n' result in one
or two newlines (or one-and-a-half)?  Depending on the platform you can
argue that it should write out '\r\r', '\r\n\r\n' or '\n\n' or if on Windows
that it should be left alone as '\r\n'.  There is, of course, the current
'\r\r\n' behavior as well.  I don't think there's obviously one best answer.
If you want to do something esoteric, open the file in binary mode and do
whatever you like.

Skip
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to