I have a class which uses a temporary directory for storing data.  I
would like that directory to be removed when the class is no longer
used.  I have tried removing the temporary directory from the class
destructor, however, it was never called.  After I while I traced the
problem to the class having a reference to it's own function.  Here is
a simplified model.

test.py
class Foo:
    def __init__(self):
        print "Hello"
        self.f = self.fxn

    def __del__(self):
        print "Bye"

    def fxn(self):
        print "function"

a = Foo()

running python test.py I get
Hello

Is this an expected behavior or a bug in python?  If this is expected
any suggestions for working around this.  I would like to avoid having
to call the destructor explicitly.

Thanks,

Marcin
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to