[Python-ideas] Pythonic buffering in Py3 print()

anatoly techtonik techtonik at gmail.com
Mon Jan 9 13:21:31 CET 2012


On Mon, Jan 9, 2012 at 1:53 PM, Devin Jeanpierre <jeanpierreda at gmail.com>wrote:

> > In Python 2 "print 'something', statement calls were unbuffered and
> > immediately appeared on screen.
>
> No, they weren't.
>

 --- cut py2print.py ---
from time import sleep

while 1:
  sleep(1)
  print ".",
--- cut ---

This produces one dot every second with Python 2.7.2 on Windows.

Python doesn't do any extra buffering or flushing. Usually your
> terminal emulator line-buffers stdout. If you don't print a newline
> (in Python 2 OR 3) then it doesn't show up until you either flush
> (sys.stdout.flush()) or send a newline.


I assume you use Linux. Do you agree that for cross-platform language some
behavior should be made consistent?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120109/e362d7da/attachment.html>


More information about the Python-ideas mailing list