[Python-Dev] Re: [pygtk] How to delete Gtk objects
Skip Montanaro
skip@pobox.com (Skip Montanaro)
Wed, 10 Oct 2001 14:21:21 -0500
(adding python-dev to this conversation because decisions about missing
special methods vis a vis PEP 252/253 seem to me to definitely belong in
that space.)
>> I think that there may be some problems with extended types and
>> __del__?
Matt> For example:
Matt> class myList(type([])):
Matt> def __del__(self):
Matt> print "list dealloced"
Matt> list = myList()
Matt> list.append("foo")
Matt> list.append("bar")
Matt> del list
Matt> never prints list delloced.
My guess (without examining any code) is that __del__ is not implemented for
new-style classes. There is this rather cryptic note at the end of PEP 253:
- open issues:
...
- do we need __coerce__, __del__?
...
which leads me to believe that __del__ would not be called in the current
implementation. If people are going to be subclassing more than the
traditional builtin types I think __del__ methods will have to be supported.
Skip