[Tutor] File IO flush

Kent Johnson kent37 at tds.net
Mon Dec 8 18:55:55 CET 2008


On Mon, Dec 8, 2008 at 12:15 PM, Sander Sweers <sander.sweers at gmail.com> wrote:
> Hello All, I was playing around with the zipfile module and wrote a
> simple script to unzip a zip file. I then looked around on the
> internet and found the recipe 252508 [1] on the active state cookbook
> website.
>
> In this recipe the author calls flush() and then close() on a file
> object being written to disk. Now I understand what flush does but
> would close() also flush the buffers to disk?

Yes, close() will flush first; AFAIK there is no reason to call
flush() immediately before close() on the same file object.

Kent


More information about the Tutor mailing list