does python have useless destructors?

"Martin v. Löwis" martin at
Sun Jun 13 20:48:06 CEST 2004

John J. Lee wrote:
> If you have a file open for writing when the process exits, the data
> you've .write()ten isn't necessarily guaranteed to actually get
> written to disk. (Apparently, whether it does or not depends on the
> OS)
> So, if an exception occurs after the first .write(), and there's no
> finally: there to .close() your file, you might unexpectedly lose the
> data that's already been written.

That is not true: the data is not lost. The file is closed eventually
(e.g. when Python exits), in which case the data is flushed to disk.


More information about the Python-list mailing list