!! Non blocking IO !!

Stephan Houben stephan at pcrm.win.tue.nl
Thu Sep 30 08:24:20 EDT 1999


On Thu, 30 Sep 1999 12:56:01 +0200, Pierre Saloni <me at nospam.com> wrote:
>Hello,
>
>
>>I don't know what you mean with "non-blocking", but according to the
>>Perl manpage, the $| variable determines whether to flush the file
>>after every output operation.
>>
>>$| = 0 means do NOT flush after every operation, and this is the default.
>>Actually, that's also the way things work in Python; you have to flush
>>the buffers explicitely. Use the flush() method on the file object if you
>>want the $| = 1 effect.
>
>
>    Yes it is right ... sorry, i meant $|=1 ...
>    In fact what I want is an autoflush when I print, i do not want print to
>bufferize at all.
>    I did this in perl, but cannot find the right way in python.

Then just call sys.stdout.flush() after every print statement.
Don't forget to import sys.

Greetings,

Stephan




More information about the Python-list mailing list