super not working in __del__ ?

Christopher J. Bottaro cjbottaro at alumni.cs.utexas.edu
Thu Feb 17 16:58:05 EST 2005


Jeff Shannon wrote:

> Python's __del__() is not a C++/Java destructor.

Learn something new everyday...  What is it then?  Excuse my ignorance, but
what are you suppose to do if your object needs to clean up when its no
longer used (like close open file handles, etc)?  Are you use supposed to
make a method called Destroy() or something and require users to call it
when the object is about to be deleted?  That seems to put the burdon of
ref counting on the user.  I read in the programming FAQ about making an
explicit close() method that can be called multiple times.  It just seems
like kinda a pain when a C++/Java style destructor would nicely do what is
desired.  Should I just stop digging and chalk it up to a limitation of
Python?

I'm just trying to understand all this...

Thanks,
-- C




More information about the Python-list mailing list