In addition to writing this line, write will also return the number of characters (in fact, bytes, try sys.stdout.write('γΈllΓΆ') ). Since the python console prints the return value of each expression to stdout, the return value is added to the actual printed value.
Since write does not add new lines, it looks like the same line.
You can check this with a script containing this:
#!/usr/bin/python import sys ret = sys.stdout.write("Greetings, human!\n") print("return value: <{}>".format(ret))
This script should, when executing the output:
Greetings, human! return value: <18>
This behavior is mentioned in the docs here .
source share