[Tutor] creating text files

Michael Janssen Janssen at rz.uni-frankfurt.de
Thu Dec 11 13:04:34 EST 2003


On Thu, 11 Dec 2003, Stanfield, Vicki {D167~Indianapolis} wrote:

> A follow-up question if you don't mind....
>
> I open a log file while my program is running, but sometimes the program
> crashes and leaves no log file. Is there any way to write the file prior
> to when I actually close it. I guess I could close it and reopen it, but
> I'd rather just flush the output to the file.

file_object.flush() # writes immediatly back to disk

you might notice a performance impact when you do it very often (e.g.
several/ many times per second)

Michael



More information about the Tutor mailing list