[Tutor] ensuring a __del__ method happens
Sean 'Shaleh' Perry
shaleh@valinux.com
Tue, 27 Mar 2001 12:56:26 -0800 (PST)
>
> The best solution is to hold on to the functions you need (not the
> module) and use those in the __del__ method. For example, I have a
> TempFile class in my mimecntl module which goes something like:
>
> class TempFile:
> <rest snipped>
> This should handle most all the cases that exist (it sounds like you'll
> want to have listdir, remove, rmdir, and others to handle any subfiles).
>
Hmmm, will look into this. I am still confused because I have my del method
printing a 'I am exiting' string which I never see.
I have Foo and TemporaryFoo. Foo does not have a __del__ method. TemporaryFoo
does. The class is instantiated as:
if need_temp:
foo = TemporaryFoo()
else:
foo = Foo()
..... # time passes
when foo is destroyed, either by sys.exit(), an exception, whatever I never see
TemporaryFoo's del method. Do I need to add a dummy __del__ method to the base
class?