using modules in destructors

Michele Simionato michele.simionato at gmail.com
Fri Oct 24 10:06:03 EDT 2008


This is expected behavior (see http://www.python.org/doc/essays/cleanup)
but it is definitely a wart of Python. The best advice I can give you
is *never* use __del__. There are alternatives,
such as the with statement, weak references or atexit.
See for instance  http://code.activestate.com/recipes/523007/
If you Google in this newsgroup for __del__ you will find a lot of
discussion.

  Michele Simionato



More information about the Python-list mailing list