cleanup after exceptions

Padraig at Padraig at
Thu Dec 18 20:11:12 CET 2003


I'm a little confused why objects
are not deleted after they go
out of scope due to an exception?

For e.g.

 >>> import time
 >>> def f():
 >>>     myfile=open("file.test","w")
 >>>     myfile.write("not flushed\n")
 >>>     exception=throw
 >>> f()
 >>> time.sleep(10)

The file is not written/closed until
the python interpreter exits.
The same thing applies to other objects.


More information about the Python-list mailing list