Unbound names in __del__

Torsten Bronger bronger at physik.rwth-aachen.de
Thu Jun 16 09:51:57 EDT 2005


Hallöchen!

When my __del__ methods are called because the program is being
terminated, I experience difficulties in calling functions that I
need for a clean shutdown of my instances.  So far, there has been
only one of these functions, and a class-local alias solved the
problem.  However, now there are many of them.

Is there a way to detect whether the program is being terminated?
(In this case, I wouldn't care and return from __del__ immediately.)

Or do you know a cleaner solution?  For example, if I have

import vpp43

would it help to say

def __init__(self):
   __vpp43 = vpp43
   ...

to guarantee that I can access all the routines in vpp43 in the
__del__ method?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus



More information about the Python-list mailing list