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.cycle does exactly that. For arbitrary
> offsets or different steps, you'd have to combine cycle with islice.

*slap forehead* Figures.. I actually read the itertools.cycle
documentation but I didn't realize that it was (almost) equivalent to
my code. Thanks for that.


-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to