Newbie (read: pot. stupid) question on objects/namespaces
fredp at multimania.com.nospam
Tue Aug 31 12:06:57 EDT 1999
stephan at pcrm.win.tue.nl (Stephan Houben) said :
>> Duh. Is this a total "no-no", or what ? If this is only for a handful
>> of instances that are supposed to persist through the entire program
>> lifetime, is it okay to explicitely del() them at the end or not ?
>No, this was just a word of caution!
>If it's just a handful of instances, don't bother.
Exactly 18 :-)
>However, if you want to get rid of them, del'ling them doesn't work.
>You must break the circularity to get them garbage collected.
>In my original example:
>> >class Baz:
>> > def __init__(self):
>> > self.x = MyClass(self)
>,when you have created an instance:
>baz = Baz()
>,you can break the circularity by either doing:
>baz.x = None
>baz.x.owner = None
>But don't do this in the __del__() method of Baz!
>That's not good enough. You have to do this in order to
>get __del__() called in the first place.
Got that. Once again, thanks !
>Now, if you use JPython, you have real garbage collection, and
>all this is a non-issue.
Er, no. One thing at a time :-)
YAFAP : http://www.multimania.com/fredp/
More information about the Python-list