[Tutor] Replacement for __del__

Strax-Haber, Matthew (LARC-D320) matthew.strax-haber at nasa.gov
Tue May 19 00:21:04 CEST 2009


To all the generous Python coders on this list,

I've been told numerous times that using __del__ is not the way to handle
clean-up because it is finicky. Fine. However, how should I handle the
following problem:
A folder is created during object instantiation. This is necessary because
multiple other methods depend on the existence of that folder, and in the
future things may be running in parallel so it has to be there for the
entire life of the object. Before the object is deleted, I want that temp
folder to be deleted (ala shutil.rmtree). Is there a better way to do this?

Regardless of whether I should be using __del__, can anyone explain this to
me (to satisfy curiosity):
My class sub-types dict. In __init__, there is a call to
self.update(pickle.load(<some file>)). For some reason, this triggers
__del__. Why?

Thanks in advance to whomever responds. I hope I was clear enough.
-- 
~ Matthew Strax-Haber
National Aeronautics and Space Administration
Langley Research Center (LaRC)
Co-op, Safety-Critical Avionics Systems Branch
Student, Northeastern University
W: 757-864-7378; C: 561-704-0029
Matthew.Strax-Haber at nasa.gov



More information about the Tutor mailing list