I create same object in Tree, I want to update Tree, when I need to
delete subtree.
If where no references, I can't do that. some thing like blow:
for i in list:
del i
Mainly because you are creating an "i" name each time, and then
removing just that "i" name. To delete something /inside/ a list, you
have to go into the container itself. The contents of a list are merely
references to the actual object. Of course, if you have an external name
somewhere, you still won't get rid of the object
while len(lst): #list is a built-in function, don't use as a name
del lst[0] #delete the first item IN the lst
a = someObject(1)
b = someObject(2)
lst = [ a, b ]
del lst[0] #removes first item in the list, but the name a is still
#around, so someObject(1) is still in memory
del b #removes the "b" name, but lst still has a reference to the
# someObject(2)
del lst[0] #removes the first (only) item in the list, a reference
#to someObject(2). No more references to someObject(2)
#so garbage collection gets rid of someObject(2)
del a #removes the only remaining reference to someObject(1)
#garbage collector gets rid of the object.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/