Flush

Richie Hindle richie at entrian.com
Tue Jul 9 06:32:20 EDT 2002


> Anyone know if python has a flush() function like PHP,
> to buffer dump in CGI ?

As others have said, sys.stdout.flush() will do this.  An alternative is
to change the #! line of your CGI script to run "python -u".  This has two
effects:

 o it makes both output channels unbuffered, which means you don't need to
   remember to flush them

 o it puts the output channels into binary mode, which means that your
   script is portable between platforms with different line ending
   sequences (Windows, Unix, Mac) if you explicitly end your HTTP headers
   with '\r\n'.

-- 
Richie Hindle
richie at entrian.com




More information about the Python-list mailing list