how do i disable buffered output, like Perl's '$|=1'?
Fredrik Lundh
fredrik at effbot.org
Sun Jan 14 13:01:47 EST 2001
floR wrote:
> Not exactly what I meant, I think.
It does exactly what you want -- but sure, there are
other ways to do the same thing:
> Okay, what I want to do in particular, is to send 'print' commands to the
> browser in intervals, without buffering, something like the following:
>
+ import sys
> print 'Content-type: text/html\n\n'
> countdown = 10
> while countdown:
> print countdown
> countdown = countdown - 1
+ sys.stdout.flush() # flush output buffers
> sleep(1)
>
> so that the countdown seems to happen in your browser, instead of waiting
> for 10 seconds for the string '10 9 8 7 6 5 4 3 2 1' to appear.
(this assumes that your server sends data to the client
as soon it arrives from the CGI script, of course).
Cheers /F
More information about the Python-list
mailing list