using modules in destructors

Scott David Daniels Scott.Daniels at Acm.Org
Mon Oct 27 13:40:12 EDT 2008


samtygier at gmail.com wrote:
> It seems to me that deleting local instances before imported modules
> would solve the problem. Is it not possible for the interpreter to get
> this right? Or are there cases where this would break stuff.
> 
> It seems rather unpythonic for the __del__() method to become
> unpredictable at exit.
What would you have different? How would you define the end of a
Python program?  Would all modules and globals remain, and then
darkness?  Would the modules get removed in alphabetical order?
....

The core of the problem is that there is ((and possibly can be)
no good definition of what happens after SystemExit leaves the
__main__ module.


--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list