__del__ in classes derived from Tkinter classes
Petr Klyushkin
petrk at pochtamt.ru
Mon Jul 22 03:07:58 EDT 2002
Hello, Fredrik!
>>>>> "Fredrik" == Fredrik Lundh writes:
Fredrik> Petr Klyushkin wrote:
>> So, when will Python object be destroyed? Suppose, I have
>> following code:
>>
>> def f(): test2 = Test() f()
>>
>> When will test2 (Python object! not a Tk widget it represents) be
>> destroyed?
Fredrik> maybe when the function returns. maybe somewhat later.
Fredrik> maybe when the interpreter exits. possibly never at all.
Fredrik> (and using __del__ is usually bad style even outside
Fredrik> Tkinter, but that's another story).
>> Why?
Fredrik> you don't know when they're called, you don't know if
Fredrik> they're called, and you don't know in what state the system
Fredrik> is when they are called.
Fredrik> for more info, search google for "finalizers are bad", or
Fredrik> variations thereof.
I understand now, thank you for help.
--
C'ya, Peter.
--=[petrk at pochtamt.ru]=--=[http://petrk.pochtamt.ru]=--
--=[ICQ 89449080]=--=[Jabber dassburger at jabber.ru]=--
More information about the Python-list
mailing list