- Command line and environment on Python 3 docs - how to use the
Run in unbuffered mode, so that output is printed immediately rather than when the buffer reaches a certain size.
There are multiple ways to achieve this.
$ python -u
Or if you are not using
/usr/bin/env python you can add the flag to your script.
PYTHONUNBUFFERED in the shell or within your script on
Or within a script on print.
print('Hello, World!', flush=True)
Or with a partial:
import functools print = functools.partial(print, flush=True) print('Hello, World!')