Stupid q: Where is the destructor?

Gerrit Holl gerrit at NOSPAM.nl.linux.org
Wed Aug 23 10:21:25 EDT 2000


On Wed, 23 Aug 2000 16:05:52 +0200, Kjell Kolsaker wrote:
> Hi,
> 
> I am new to Python, so excuse me if I ask for an obvious thing,
> Didn't find anything in the tutorial, nor in the faq.
> 
> I want to define a class with some side effect in the
> constructor that I need to clean up whenever an object is deleted.
> Default destruction doesn't help me. In the documentation,
> I find __init__, but no "__finalize__" or whatever it should be called.
> 
> Do anybody know the answer? Have I missed something obvious?

You have indeed. You are looking for __del__.
For your information, it can be found at the following place in the
docs:

Language Reference -> Data model -> Special method names -> Basic customization

URL: http://www.python.org/doc/current/ref/customization.html

And the name is............ __del__!

regards,
Gerrit.

-- 
1010111 1101001 1100101 0100000 1100100 1101001 1110100
0100000 1101100 1100101 1100101 1110011 1110100 0100000
1101001 1110011 0100000 1100111 1100101 1101011 0100001



More information about the Python-list mailing list