[Python-Dev] Next version of PEP278 - universal newline support (original) (raw)

Guido van Rossum guido@python.org
Thu, 14 Mar 2002 11:17:29 -0500


Am I the only one who wants universal newlines without a new mode character? Ideally I'd like existing code that works with text files to accept any line ending.

Me too. But it opens up the nasty problem of the gazillions of Unix-only programmers who never use 'b' for binary files. We've fixed that in the std library (since it's cross platform), but I'm not too comfortable with imposing this on everybody without a transition period, given that this is both common knowledge and has "just worked" for 12 years in Python.

I wonder if it would make sense to put a warning when people use f.read(n) on a file opened in text mode? I think f.read(n) is an almost sure sign that they're seeing the file as binary data. However, f.read() or f.read(-1) is used to slurp in text as well, so should not trigger the warning.

Opinions?

--Guido van Rossum (home page: http://www.python.org/~guido/)