How to flush print

Gerrit gerrit at
Sun Mar 7 10:27:44 CET 2004

Jay Davis wrote:
> If you open a file the usual way, you can flush
> the output buffer with .flush().  How do you flush
> the output buffer of a print command, either
> 'print string' or 'print >>ofile, string' ?

print string

is really short for

sys.stdout.write("%s" % string)

so you can flush it with


Weather in Amsterdam Airport Schiphol, Netherlands 07/03 08:55 UTC:
	6.0°C Few clouds partly cloudy wind 3.1 m/s W (-2 m above NAP)
Asperger's Syndrome - a personal approach:

More information about the Python-list mailing list