from the interactive prompt:
>>> import sys
>>> sys.stdout.write('is the')
is the6
what is ‘6’ doing there?
another example:
>>> for i in range(3):
... sys.stderr.write('new black')
...
9
9
9
new blacknew blacknew black
where are the numbers coming from?
In 3.x the
writemethod of a file object returns the number of bytes written, and the interactive prompt prints out the return value of whatever you are running. So you print out'is the'(6 bytes), and the interpreter then prints out 6 (the return from write). See the relevant docs for 3.1.This does not happen before 3.0 as the write method returned
None, and therefore nothing was printed.