sys.stderr.write returns string length in Python 3

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan G Isaac

    sys.stderr.write returns string length in Python 3

    Is this new behavior intentional? ::
    >>sys.stderr.wr ite("thisisates t\n")
    thisisatest
    12

    Here is the reason for it:
    >>help(sys.stde rr.write)
    Help on method write in module io:
    write(self, s: str) method of io.TextIOWrappe r instance

    Thank you,
    Alan Isaac
  • Benjamin

    #2
    Re: sys.stderr.writ e returns string length in Python 3



    Alan G Isaac wrote:
    Is this new behavior intentional? ::
    Yes, it's in the PEP http://www.python.org/dev/peps/pep-3116/.
    >
    >>sys.stderr.wr ite("thisisates t\n")
    thisisatest
    12
    >
    Here is the reason for it:
    >
    >>help(sys.stde rr.write)
    Help on method write in module io:
    write(self, s: str) method of io.TextIOWrappe r instance
    >
    Thank you,
    Alan Isaac

    Comment

    • Alan G Isaac

      #3
      Re: sys.stderr.writ e returns string length in Python 3

      Benjamin wrote:Thanks.
      Can you give me an example of using the returned value?
      Alan

      Comment

      • Fredrik Lundh

        #4
        Re: sys.stderr.writ e returns string length in Python 3

        Alan G Isaac wrote:
        Can you give me an example of using the returned value?
        it's for consistency with stream objects that support raw I/O (as
        described in the PEP). when using buffered I/O, you can ignore it.

        </F>

        Comment

        Working...