I think this may be because in Python 2, there is a coupling between stdin and stderr (in the C stdlib code) that flushes stdout when you read stdin. This doesn&#39;t seem to be required by the C std, but most implementations seem to do it. <a href="http://stackoverflow.com/questions/2123528/does-reading-from-stdin-flush-stdout">http://stackoverflow.com/questions/2123528/does-reading-from-stdin-flush-stdout</a><br>

<br>I think it was a nice feature but I can see problems with it; apps that want this behavior ought to bite the bullet and flush stdout.<br><br><div class="gmail_quote">On Fri, Jan 13, 2012 at 7:34 AM, anatoly techtonik <span dir="ltr">&lt;<a href="mailto:techtonik@gmail.com">techtonik@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Posting to python-dev as it is no more relates to the idea of improving print().</div><div><br></div><div><br></div>

sys.stdout.write() in Python 3 causes backwards incompatible behavior that breaks recipe for unbuffered character reading from stdin on Linux - <a href="http://code.activestate.com/recipes/134892/" target="_blank">http://code.activestate.com/recipes/134892/</a>  At first I though that the problem is in the new print() function, but it appeared that the culprit is sys.stdout.write()<div>



<br></div><div>Attached is a test script which is a stripped down version of the recipe above.<div>
<br></div><div>If executed with Python 2, you can see the prompt to press a key (even though output on Linux is buffered in Python 2).</div><div><div>With Python 3, there is not prompt until you press a key.</div><div>
<br></div><div>Is it a bug or intended behavior? What is the cause of this break?</div><span class="HOEnZb"><font color="#888888"><div>-- </div><div><div>anatoly t.<br><br></div></div></font></span></div>
</div>
<br>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/guido%40python.org" target="_blank">http://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)<br>