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.

classification
Title: writing to stdout prints extraneous size character
Type: Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: dtorp, zach.ware
Priority: normal Keywords:

Created on 2018-01-24 20:54 by dtorp, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg310631 - (view) Author: David Albert Torpey (dtorp) Date: 2018-01-24 20:54
$ python3.5
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 08:49:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.write('python')
python6
msg310632 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2018-01-24 20:59
This is not a bug, it's a side effect of using the REPL for this test and not assigning the return value of `sys.stdout.write` to anything.  Try the following:

>>> import sys
>>> character_count = sys.stdout.write('python\n') # note trailing newline
python
>>> character_count
6
>>> print('python')
python
>>> 

Or try saving your original test to a file and running it.
msg310633 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2018-01-24 21:00
Of course, I realize after clicking "submit" that my character count there is actually wrong, and should be 7.  That's what I get for writing out the example instead of actually running and copying it :)
History
Date User Action Args
2022-04-11 14:58:57adminsetgithub: 76837
2018-01-24 21:00:22zach.waresetmessages: + msg310633
2018-01-24 20:59:04zach.waresetstatus: open -> closed

nosy: + zach.ware
messages: + msg310632

resolution: not a bug
stage: resolved
2018-01-24 20:54:41dtorpcreate