[Python-ideas] Pythonic buffering in Py3 print()
Guido van Rossum
guido at python.org
Wed Jan 11 04:14:11 CET 2012
On Tue, Jan 10, 2012 at 6:36 PM, MRAB <python at mrabarnett.plus.com> wrote:
> On 11/01/2012 01:59, Nick Coghlan wrote:
>> On Tue, Jan 10, 2012 at 8:15 PM, Masklinn<masklinn at masklinn.net**>
>>> 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")
>> Given that 'print' is a function in Python 3, it's easy to redefine it
> to flush. I've done it on occasion.
Heh, that's exactly why we made it a function. So is adding e.g. a
force_flush flag -- though personally I would be fine calling it "flush"
despite the possibility that the underlying stream might still flush when
it is not explicitly requests.
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas