This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: sys.stdout.write printing length of string
Type: behavior Stage: resolved
Components: Versions: Python 3.3
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: firatozgul, kushal.das
Priority: normal Keywords:

Created on 2012-11-12 06:51 by firatozgul, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg175419 - (view) Author: Firat Ozgul (firatozgul) Date: 2012-11-12 06:51
On Python 3.3 under Windows and GNU/Linux, sys.stdout.write prints the length of string along with the string itself:

>>> sys.stdout.write("a_string")


Note the '8' at the end of 'a_string'.

Is it expected behavior?
msg175420 - (view) Author: Firat Ozgul (firatozgul) Date: 2012-11-12 07:22
Although I do not know the reason for change, it seems that this is expected behavior as of Python 3.0 in interactive shell. Closing the record as 'invalid'.
msg175421 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2012-11-12 07:23
sys.stdout.write returns the length of the string it printed. 
try these:

x = sys.stdout.write("abc")
print x

or from console
python -c 'import sys ; sys.stdout.write("abc")'
msg175422 - (view) Author: Firat Ozgul (firatozgul) Date: 2012-11-12 07:28
Thank you for the explanation, kushaldas.
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60663
2012-11-12 07:44:42ezio.melottisettype: behavior
components: - None
stage: resolved
2012-11-12 07:28:04firatozgulsetmessages: + msg175422
2012-11-12 07:23:31kushal.dassetnosy: + kushal.das
messages: + msg175421
2012-11-12 07:23:10firatozgulsetstatus: open -> closed
2012-11-12 07:22:44firatozgulsetresolution: not a bug
messages: + msg175420
2012-11-12 06:51:28firatozgulcreate