How to flush print

Gerrit gerrit at nl.linux.org
Sun Mar 7 04:27:44 EST 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

sys.stdout.flush()

Gerrit.
-- 
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:
	http://people.nl.linux.org/~gerrit/english/




More information about the Python-list mailing list