circular iteration

Fredrik Lundh fredrik at pythonware.com
Fri Jan 21 18:17:11 CET 2005


"Flavio codeco coelho" wrote:

> is there a faster way to build a circular iterator in python that by doing this:
>
> c=['r','g','b','c','m','y','k']
>
> for i in range(30):
>    print c[i%len(c)]

have you benchmarked this, and found it lacking, or are you just trying
to optimize prematurely?

</F> 






More information about the Python-list mailing list