Python to Perl Conversions

Fredrik Lundh fredrik at pythonware.com
Sun Aug 22 13:08:07 EDT 1999


William Tanksley wrote:
> Python, OTOH, doesn't seem to have a way to set a file's flushing
> properties -- you have to explicitly flush whenever you need it.  True?

you can open the file without buffering (pass 0 as
the third argument to open).

this cannot be changed after you've opened the file,
though (python's I/O is based on stdio, and some stdio
implementations crash if you try to change the buffer
size after you've accessed the file).

alternatively, you can wrap the file object in a
small class which explicitly calls flush after each
write.

</F>





More information about the Python-list mailing list