Python Forum

Full Version: stdout
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
is there a way, that works in both Python2 and Python3, to set stdout to always automatically flush at the end of every print command or function, at least in the cases which output a newline (in more cases is ok)? in many scripts i do stdout.flush() after each print and would like to have an easier way but i don't want to have to fake it with os.write(). i do know Python3 supports flush=True in the print function, but i still want these scripts to work on Python2. the reason is to be sure output order remains consistent around various other things the script might be doing.