Flushing print()

Daniel Yoo dyoo at hkn.eecs.berkeley.edu
Thu Feb 24 21:34:42 EST 2005


gf gf <unknownsoldier93 at yahoo.com> wrote:
: Is there any way to make Python's print() flush
: automatically, similar to...mmm...that other
: language's $|=1 ?


Hello gf gf,

Yes; you can use the '-u' command line option to Python, which will
turn off stdout/stderr buffering.


: If not, how can I flush it manually?  sys.stdout.flush() didn't
: seem to work.

Hmmmm, that's odd.  sys.stdout.flush() should do it.  How are you
testing that stdout isn't flushing as you expect?


Best of wishes to you!



More information about the Python-list mailing list