Cycle around a sequence

Serhiy Storchaka storchaka at gmail.com
Thu Feb 9 11:10:41 CET 2012


08.02.12 22:15, Terry Reedy написав(ла):
> To make a repeating rotator is only a slight adjustment:
>
>     k = n - len(seq)
>     while True:
>         i = k
>         while i < n:
>             yield seq[i]
>             i += 1

     for i in range(n, len(seq)):
         yield seq[i]
     while True:
         for x in seq:
             yield x




More information about the Python-list mailing list