Steven D'Aprano schreef op de 2e dag van de slachtmaand van het jaar 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?

Script 1:

    #!/usr/bin/env python3.1
    import sys
    print(sys.stdin.readlines())

Output:

    ~ test.py < text
    ['a\rbc\rdef\r']    


Script 2:

    #!/usr/bin/env python3.1
    import io, sys
    sys.stdin = io.TextIOWrapper(sys.stdin.detach(), newline=None)
    print(sys.stdin.readlines())

Output:

    ~ test.py < text
    ['a\n', 'bc\n', 'def\n']


-- 
Peter Kleiweg
http://pkleiweg.home.xs4all.nl/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to