does python have useless destructors?

John J. Lee jjl at pobox.com
Sun Jun 13 20:04:09 EDT 2004


"Martin v. Löwis" <martin at v.loewis.de> writes:

> 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.

I guess you're right.

Points for anyone able to guess what I was thinking of (I don't know
myself :-)...


John



More information about the Python-list mailing list