enabling universal newline

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Nov 3 00:09:34 CET 2012

On Fri, 02 Nov 2012 23:22:53 +0100, Peter Kleiweg wrote:

> In Python 3.1 and 3.2
> At start-up, the value of sys.stdin.newlines is None, which means,
> universal newline should be enabled. But it isn't.

What makes you think it is not enabled?

sys.stdin.newlines shows you the newlines actually seen. Until you put 
text including newlines through stdin, it will remain None.


For example, I have Python built with universal newlines, but 
stdin.newlines remains None:

py> f = open('test.txt')
py> f.newlines
py> f.readlines()
['a\n', 'b\n', 'c\n', 'd\n']
py> f.newlines
('\r', '\n', '\r\n')
py> sys.stdin.newlines is None


More information about the Python-list mailing list