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

MRAB python at mrabarnett.plus.com
Wed Jan 11 03:36:23 CET 2012

On 11/01/2012 01:59, Nick Coghlan wrote:
> On Tue, Jan 10, 2012 at 8:15 PM, Masklinn<masklinn at masklinn.net>
> wrote:
>>> So the keyword argument means "do or don't call flush() method of
>>> the file."
>> That's not clear from its name since the flushing behavior can
>> depend on the underlying stream type. force_flush would be closer
>> to the actual meaning of the param.
> +0 for being able to write print("whatever", force_flush=True)
> instead of having to do:
> import sys # somewhere in the file
 > print("whatever")
> sys.stdout.flush()
Given that 'print' is a function in Python 3, it's easy to redefine it
to flush. I've done it on occasion.

More information about the Python-ideas mailing list