I inherited a UserList class from list and implemented the following method to remove entries which are marked deleted
def purge_deleted(self):
for element in list.__iter__(self):
if ele.mark_deleted < 1:
self.remove(element)
the element in itself is a complicated entity having methods overriding comparison operators
Questions
- Will the above code successfully work in removing the objects?
- How does python internally works to remove the elements from the list?
- Will it not create a problem when we simultaneously iterate and modify the same list?