[Tutor] destructor methods

Andrew Wilkins toodles@yifan.net
Sat, 1 Dec 2001 01:29:38 +0800


> Hi everyone,

Hiya

>
> I've started looking through the C++ code for that plagiarism program
> 'Copyfind'. I notice that the author has a destructor method to get rid of
> instances of his 'document' class. I don't recall any Python programs that
> use destructors (I'm not an accomplished object-oriented programmer). Does
> Python every use them? I understand that Python's garbage collection
> automatically takes care of that sort of thing.

When defining a class, you can define a method called __del__ to handle what
happens in the deletion, so it has the desired effect. Look for more in
"3.3.1 Basic Customisation" in the Python Reference Manual.

> -Tim
>
> --
> Tim Wilson      |   Visit Sibley online:   | Check out:
> Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
> W. St. Paul, MN |                          | http://slashdot.org
> wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com