How do I force Python's print function to output to the screen?
This is not a duplicate of Disable output buffering - the linked question is attempting unbuffered output, while this is more general. The top answers in that question are too powerful or involved for this one (they're not good answers for this), and this question can be found on Google by a relative newbie.
Also as suggested in this blog one can reopen
sys.stdout
in unbuffered mode:Each
stdout.write
andprint
operation will be automatically flushed afterwards.I did it like this in Python 3.4:
Loved Dan's solution! For python3 do:
Running
python -h
, I see a command line option:Here is the relevant doc.
With Python 3.x the
print()
function has been extended:So, you can just do:
Python Docs Entry
Why not try using an unbuffered file?
OR