termios disappears during object deletion

Fredrik Lundh fredrik at pythonware.com
Thu Sep 9 03:01:13 EDT 1999


Brien Barton <brien.barton at boeing.com> wrote:
> Fredrik's solution (see below) does work, but I find this behavior
> extremely unintuitive and error prone.  Why should correct code that
> works when I explicitly delete my object, not work when the program
> terminates?  Isn't the whole idea of having the __del__ method to make
> sure things get cleaned up properly?  Why can't all __del__ methods be
> executed BEFORE Python starts deleting globals?

well, that __del__ method was probably called when
Python deleted a global object...

just noticed that the essay I pointed you to mentions
a way to make it more likely that your globals are deleted
before the modules start disappearing:

    C1. In an order determined by the dictionary
    hashing of the names, set all names to None
    that start with exactly one underscore. 

    /.../

    Since imported module or function names
    generally don't begin with an underscore,
    this means that such objects can be
    guaranteed that any imported modules
    or functions still exist when they are
    deleted -- provided, of course, that the only
    reference to them is in the module.

better than nothing, I suppose...

</F>





More information about the Python-list mailing list