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

Devin Jeanpierre jeanpierreda at gmail.com
Mon Jan 9 14:25:23 CET 2012


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

Weird. Must be a windows thing.

> I assume you use Linux. Do you agree that for cross-platform language some
> behavior should be made consistent?

Yes. I guess that's why they changed the behavior of print on Windows
in Python 3.

-- Devin

On Mon, Jan 9, 2012 at 7:21 AM, anatoly techtonik <techtonik at gmail.com> wrote:
> 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?



More information about the Python-ideas mailing list