Python: Flushing while printing
Since Python 3.3, you can force the normal
print()
function to flush without the need to usesys.stdout.flush()
; just set theflush
keyword argument toTrue
. From the documentation:
print(*objects, sep=' ', end='', file=sys.stdout, flush=False)
Whether output is buffered is usually determined by file, but if the flush keyword argument is true, the stream is forcibly flushed.
Via SO.
Leave a comment