Having trouble deleting objects from a list...

KraftDiner bobrien18 at yahoo.com
Wed Oct 19 21:16:24 EDT 2005


I have a list, and within it, objects are marked for deletion.
However when I iterate through the list to remove objects
not all the marked objects are deleted..
here is a code portion:

			i = 0
			for obj in self.objList:
				if obj.mouseHit:
					print 'delete + ' + `i`
					self.objList.pop(i)
					flag = True
				else:
					i = i + 1
				print `i`

I can't see what I'm doing wrong!
It seems like the last selected object is the one that is not
deleted...




More information about the Python-list mailing list