P3 weird sys.stdout.write()

Jerzy Jalocha N jjalocha at gmail.com
Mon Aug 24 09:13:40 EDT 2009


I've stumbled upon the following in Python 3:

Python 3.0.1+ (r301:69556, Apr 15 2009, 15:59:22)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.write("")
0
>>> sys.stdout.write("something")
something9
>>>

write() is appending the length of the string to it's output. That's
not how it worked in 2.6.

What's the reason for this? Is this intended? I couldn't find a bug
report for this.



More information about the Python-list mailing list