Re: For-each behavior while modifying a collection

2013-11-29 Thread Valentin Zahnd
2013/11/28 Ned Batchelder : > On 11/28/13 10:49 AM, Valentin Zahnd wrote: >> >> Hello >> >> For-each does not iterate ober all entries of collection, if one >> removes elements during the iteration. >> >> Example code: >> >> def keepByValue

For-each behavior while modifying a collection

2013-11-28 Thread Valentin Zahnd
Hello For-each does not iterate ober all entries of collection, if one removes elements during the iteration. Example code: def keepByValue(self, key=None, value=[]): for row in self.flows: if not row[key] in value: self.flows.remove(row) It is clear why it behaves on th