[Tutor] How to override getting items from a list for iteration

Peter Otten __peter__ at web.de
Sun Feb 10 16:25:27 CET 2013


Peter Otten wrote:

> def __iter__(self):
>     for i in range(len(self)):
>         return self[i]

That should of course be 'yield', not 'return' 




More information about the Tutor mailing list