strange __del__ behavior
bh at intevation.de
Wed Jun 9 20:22:26 CEST 2004
John Hunter <jdhunter at ace.bsd.uchicago.edu> writes:
> For debugging purposes, I would like to know when C instances are
> being deleted; that's why I inserted the __del__ print method. Is
> there any way to get that info w/o defining __del__ and thereby
> screwing up python's garbage collection?
I've sometimes used something like this:
def __init__(self, message):
self.message = message
self.__del = DelReporter("__del__: %r" % self)
Even if a C-instance is part of a cycle, its __del member is not, so
it's __del__ doesn't affect garbage collection.
Intevation GmbH http://intevation.de/
More information about the Python-list