Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40728 > unrolled thread

Re: iterating over a list as if it were a circular list

Started byChris Angelico <rosuav@gmail.com>
First post2013-03-07 20:28 +1100
Last post2013-03-07 20:28 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: iterating over a list as if it were a circular list Chris Angelico <rosuav@gmail.com> - 2013-03-07 20:28 +1100

#40728 — Re: iterating over a list as if it were a circular list

FromChris Angelico <rosuav@gmail.com>
Date2013-03-07 20:28 +1100
SubjectRe: iterating over a list as if it were a circular list
Message-ID<mailman.2995.1362648484.2939.python-list@python.org>
On Thu, Mar 7, 2013 at 8:23 PM, Sven <svenito@gmail.com> wrote:
> Now I would like to iterate over P and place one N at each point. However if
> you run out of N I'd like to restart from N[0] and carry on until all the
> points have been populated.

Check out itertools.cycle, it should do what you want.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web