what should __iter__ return?
nfdisco at gmail.com
Fri Sep 3 21:35:48 CEST 2010
What is better:
for i in len(self):
return iter([self[i] for i in range(len(self))])
The first one, I would say is more correct,
however what if in a middle of an iteration
the object changes in length? Then, the
iterator will fail with IndexError (if items
have been removed), or it will fail to iterate
over the whole sequence (if items have
What do you think?
More information about the Python-list