P3 weird sys.stdout.write()
andre.roberge at gmail.com
Mon Aug 24 15:22:36 CEST 2009
On Aug 24, 10:13 am, Jerzy Jalocha N <jjalo... at gmail.com> wrote:
> 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("")
> >>> sys.stdout.write("something")
> write() is appending the length of the string to it's output.
Not quite right, see below.
> 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.
I don't know what the reason for the change, but try the following:
>>> out = sys.stdout.write("test\n")
What you are seeing is the concatenation of the return value of the
write() method with its output.
More information about the Python-list