[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Concerning copy
You must be thinking of some different use case than this.
Try the following code snippet. If you encounter 'skip deletes' in the
future, now you have an inkling what's causing it.
allitems = []
class Simple:
name = None
def __init__(self, name):
self.name = name
allitems.append(self)
def Destroy(self):
allitems.remove(self)
def PrintAllItems():
print "All items:"
for item in allitems:
print " %s" % item.name
def main():
for i in range(10):
Simple("Item %d" % i)
PrintAllItems()
for item in allitems:
item.Destroy()
PrintAllItems()
main()