Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40733
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.034 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'iterate': 0.09; 'cc:addr :python-list': 0.10; 'assume': 0.11; 'itertools': 0.16; 'wrote:': 0.17; 'items.': 0.17; 'email addr:gmail.com>': 0.20; 'import': 0.21; "i'd": 0.22; 'cc:2**0': 0.23; '>': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'wondering': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:list': 0.28; 'run': 0.28; 'restart': 0.29; 'points': 0.29; 'skip:& 10': 0.29; 'point.': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'whatever': 0.35; 'be.': 0.36; 'late': 0.37; 'subject:: ': 0.38; 'header:Received:5': 0.40; 'due': 0.66; '2013': 0.84; 'sender:addr:chris': 0.84; 'subject:over': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=3XZ7SBm0WdxECKfC59QTkX+P/PqL2qyjSiB7M5YDBq0=; b=DLBn/WKAHsNTVJ5otjD80XJ2JPkEm+yxd+cz5b+P+D/S6PHgdHLhfR4LRqxczCrSge NWvFhMVyCjy20n7u9Ke569n1Ry5zpFWILdOvWSV5faZjb02KamYIUmTE2hl1LpEY+J3Q k3NpiXLoqBbjdIpmxthcBu11nuS99Y4ZNIb5I= |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=3XZ7SBm0WdxECKfC59QTkX+P/PqL2qyjSiB7M5YDBq0=; b=lZMEaoxaQEHIWdX8ErWnD/GzicVqSqDk8Sx3UfdWkE8FEWr+Wc0Up28hRXeYaFjiHn JySPUE4IpazKlyf5fijrYUuhBPYUpE5uaPE4ghAhb9lISSEbZ4oG3daZLvVCAmoBw1gl zcqIhYhtVPFUFbBEV8/ztg3g7wzcf4kCXGLy/C6D3LkiEFRRgIhQZa/TToaeHjtdz98W qQpLEMmZafWe0LwxMR+En58IW65K3kG3Kyh3foDZVNXVNjRJgK7tZr1xwKhhzpQXB8hY j+dZjNIvGxPLczwgCFu46eTiGfw5XR2KUUmr8r+Bb0pFsZ8Exdp3+NOk0Xps3RH43Rzo 7XuA== |
| MIME-Version | 1.0 |
| X-Received | by 10.43.45.195 with SMTP id ul3mr33415367icb.14.1362648711642; Thu, 07 Mar 2013 01:31:51 -0800 (PST) |
| Sender | chris@rebertia.com |
| In-Reply-To | <CAEH=cXWXwOf6QnNur4V3HNBZ2i13gVnOiJDOOyCZs1Putc_mug@mail.gmail.com> |
| References | <CAEH=cXWXwOf6QnNur4V3HNBZ2i13gVnOiJDOOyCZs1Putc_mug@mail.gmail.com> |
| Date | Thu, 7 Mar 2013 01:31:51 -0800 |
| X-Google-Sender-Auth | VUo7CCD9ciOH3xiDValbEreNIww |
| Subject | Re: iterating over a list as if it were a circular list |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Sven <svenito@gmail.com> |
| Content-Type | multipart/alternative; boundary=bcaec52e5f3f69614604d75260dd |
| X-Gm-Message-State | ALoCoQkvU8/Q+YwPATm8APsw/pIQOjJymgvfYYujUDAN2gWLBmmtrlVTkiGpCiZ3oJ+QNJ3TKo9r |
| Cc | Python <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2998.1362648719.2939.python-list@python.org> (permalink) |
| Lines | 46 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362648719 news.xs4all.nl 6918 [2001:888:2000:d::a6]:32957 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40733 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Mar 7, 2013 1:24 AM, "Sven" <svenito@gmail.com> wrote:
>
> I was wondering what the best approach for the following might be.
>
> Say you have a list P of points and another list N of other items. You
can always assume that
>
> len(N) <= len(P)
>
> 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.
Untested due to the late hour:
import itertools
for p, n in itertools.izip(P, itertools.cycle(N)):
# do whatever
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: iterating over a list as if it were a circular list Chris Rebert <clp2@rebertia.com> - 2013-03-07 01:31 -0800
csiph-web