[Python-Dev] Backwards incompatible sys.stdout.write() behavior in Python 3 (Was: [Python-ideas] Pythonic buffering in Py3 print()) (original) (raw)
anatoly techtonik techtonik at gmail.com
Tue Jan 17 11:59:16 CET 2012
- Previous message: [Python-Dev] Backwards incompatible sys.stdout.write() behavior in Python 3 (Was: [Python-ideas] Pythonic buffering in Py3 print())
- Next message: [Python-Dev] Backwards incompatible sys.stdout.write() behavior in Python 3 (Was: [Python-ideas] Pythonic buffering in Py3 print())
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Jan 13, 2012 at 7:19 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
On Fri, 13 Jan 2012 17:00:57 +0100 Xavier Morel <python-dev at masklinn.net> wrote: > FWIW this is not restricted to Linux (the same behavior change can > be observed in OSX), and the script is overly complex you can expose > the change with 3 lines > > import sys > sys.stdout.write('promt>') > sys.stdin.read(1) > > Python 2 displays "prompt" and terminates execution on [Return], > Python 3 does not display anything until [Return] is pressed. > > Interestingly, the
-u
option is not sufficient to make > "prompt>" appear in Python 3, the stream has to be flushed > explicitly unless the input is ~16k characters (I guess that's > an internal buffer size of some sort)"-u" forces line-buffering mode for stdout/stderr, which is already the default if they are wired to an interactive device (isattr() returning True). But this was already rehashed on python-ideas and the bug tracker, and apparently Anatoly thought it would be a good idea to post on a third medium. Sigh.
If you track this more closely, you'll notice there are four issues (surprises) from the user point of view:
- print() buffers output on Python3
- print() also buffers output on Python2, but only on Linux
- there is some useless '-u' command line parameter (useless, because the last thing user wants is not only care about Python 2/3, but also how to invoke them)
- print() is not guilty - it is sys.stdout.write() that buffers output
1-2 discussion was about idea to make new print() function behavior more 'pythonic', i.e. 'user-friendly' or just KISS, which resulted in adding a flush parameter 3 is a just a side FYI remark 4 doesn't relate to python-ideas anymore about fixing print() - it is about the cause of the problem with print() UX, which is underlying sys.stdout.write() behavior
I asked 4 here, because it is the more appropriate place not only to ask if it can be/will be fixed, but also why. The target audience of the question are developers.
Hope that helps Antoine recover from the sorrow. ;)
anatoly t. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120117/15b9d413/attachment.html>
- Previous message: [Python-Dev] Backwards incompatible sys.stdout.write() behavior in Python 3 (Was: [Python-ideas] Pythonic buffering in Py3 print())
- Next message: [Python-Dev] Backwards incompatible sys.stdout.write() behavior in Python 3 (Was: [Python-ideas] Pythonic buffering in Py3 print())
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]