On Nov 13, 2007 3:43 PM, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Tue, 2007-11-13 at 15:12 +0100, BJörn Lindqvist wrote:
> > L = somelist
> >
> > idx = 0
> > while True:
> > item = L[idx]
> > # Do something with item
> > idx = (idx + 1) % len(L)
> For begin=0 and step=1, itertools.
"BJörn Lindqvist" <[EMAIL PROTECTED]> writes:
> L = somelist
>
> idx = 0
> while True:
> item = L[idx]
> # Do something with item
> idx = (idx + 1) % len(L)
>
> wouldn't it be cool if there was an itertool like this:
>
> def circulate(L, begin = 0, step = 1):
> idx = begin
> wh
On Tue, 2007-11-13 at 15:12 +0100, BJörn Lindqvist wrote:
> L = somelist
>
> idx = 0
> while True:
> item = L[idx]
> # Do something with item
> idx = (idx + 1) % len(L)
>
> wouldn't it be cool if there was an itertool like this:
>
> def circulate(L, begin = 0, step = 1):
> idx =
L = somelist
idx = 0
while True:
item = L[idx]
# Do something with item
idx = (idx + 1) % len(L)
wouldn't it be cool if there was an itertool like this:
def circulate(L, begin = 0, step = 1):
idx = begin
while True:
yield L[idx]
idx = (idx + step) % len(L)
f