How do I control output buffering on Win32?

Wojtek Walczak gminick at bzt.bzt
Fri Aug 15 11:17:50 EDT 2008


On Fri, 15 Aug 2008 09:47:34 -0500, Grant Edwards wrote:
> When I ssh in to my Windows XP box and run Python apps, output
> from "print" and and "sys.stdout.write()" is being buffered so
> that none of the output shows up until the program exits. 
>
> From within my program how do I set output buffering to either
> line-buffered or un-buffered?  [I'm looking for the equivalent
> of the C stdio "setbuf" call.]

That's not exactly what you want, but what about creating your
own printing function and flushing at its end?

import sys
def printf(mystr):
   print mystr
   sys.stdout.flush()

-- 
Regards,
Wojtek Walczak,
http://www.stud.umk.pl/~wojtekwa/



More information about the Python-list mailing list