[PyKDE] destructor not getting called?

Fredrik Juhlin laz at strakt.com
Fri Nov 8 11:00:00 GMT 2002


On Fri, 2002-11-08 at 10:34, Greg Fortune wrote:
> On Friday 08 November 2002 12:44 am, you wrote:
> > The reason you're having problems is most likely because there is no
> > such thing as a destructor in Python. I assume that you, like many
> > before you, are treating the __del__() method as a destructor but the
> > reality is there is no guarantee that __del__() will be called on
> > program exit. The Python Language Reference recommends that you only use
> 
> ????  ack, where did you find information implying that __del__ might not get 
> called on program exit?  From my understanding, __del__ just wouldn't be 
> called until the reference count reaches 0 and the garbage collection cycle 
> executes.  That, of course, should happen for every object at program exit... 
>  If it doesn't, that would seem like a Python bug.
I got it from the Python Language Reference (a convenient link was
included in my last mail and below). To quote:
"It is not guaranteed that __del__() methods are called for objects that
still exist when the interpreter exits."
Wether or not it is a bug I'm really not qualified to say.

> > __del__() methods to "do the absolute minimum needed to maintain
> > external invariants". See
> > http://www.python.org/doc/current/ref/customization.html for more
> > information.

//Fredrik




More information about the PyQt mailing list