what should __iter__ return?
greg.ewing at canterbury.ac.nz
Wed Sep 8 03:40:48 CEST 2010
Thomas Jollans wrote:
> Hmm. Modifying an object while iterating over it isn't a great idea, ever:
I wouldn't say never. Algorithms that calculate some kind of
transitive closure can be expressed rather neatly by appending
items to a list being iterated over.
You can accommodate that kind of thing by writing the iterator
i = 0
while i < len(self):
i += 1
More information about the Python-list