does python have useless destructors?
"Martin v. Löwis"
martin at v.loewis.de
Sun Jun 13 14:48:06 EDT 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.
Regards,
Martin
More information about the Python-list
mailing list