cyclic iterators ?

tool69 kib2 at
Sat Mar 3 09:24:52 CET 2007

Paul Rubin a écrit :
> As Bruno says, you can use itertools.cycle, but the problem above is
> that you're not looping repeatedly through the list; you yield all the
> elements, then yield the first element again, then stop.  So for
> ['a','b','c']  you'd yield the sequence a,b,c,a.  

Yes, that was the problem.
Thanks for the explanation and for the cycle() function from itertool 
that I missed.

More information about the Python-list mailing list