Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20064
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.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; 'def': 0.13; 'received:209.85.214.174': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'head:': 0.16; '\xa0for': 0.16; 'wrote:': 0.18; 'thanks,': 0.19; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'message-id:@mail.gmail.com': 0.29; 'yield': 0.29; 'pm,': 0.29; 'chris': 0.30; 'thu,': 0.32; 'too': 0.33; 'try:': 0.34; 'to:addr:python-list': 0.35; 'received:209.85.214': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.38; 'think': 0.38; 'should': 0.38; 'except': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'otten': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=fud/2Rx86nldr9/IonJGkh/JqNS2ivuNaWBd8hSog1c=; b=tZl0yToYF6QYZMQarFxJyaV220iD0K+ipTCB+6L0ATqha/55omUv21l1zc4Cj2lRtH UqQ7c6QicLPiyauc8LKODog5apeJ+pRzpQwO6DqGbRb9ew4DRhdwO7TtRmuwxtKDx1xu D8L+QJ0Codr/ZFByRWEtomknuKq1zQNLLbc2Y= |
| MIME-Version | 1.0 |
| In-Reply-To | <jh00ca$7eu$1@dough.gmane.org> |
| References | <mailman.5525.1328663401.27778.python-list@python.org> <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> <CAPTjJmo2BkybBo8Kd_Hk5tapq_YrSHHCk0zJmYTO408YShGWFA@mail.gmail.com> <jh00ca$7eu$1@dough.gmane.org> |
| Date | Thu, 9 Feb 2012 21:34:45 +1100 |
| Subject | Re: Cycle around a sequence |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.5578.1328783688.27778.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1328783688 news.xs4all.nl 6901 [2001:888:2000:d::a6]:44249 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:20064 |
Show key headers only | View raw
On Thu, Feb 9, 2012 at 7:33 PM, Peter Otten <__peter__@web.de> wrote: > Chris Angelico wrote: > >> def cycle(seq,n): >> seq=iter(seq) >> lst=[next(seq) for i in range(n)] >> try: >> while True: yield next(seq) >> except StopIteration: >> for i in lst: yield i > > I think that should be spelt > > def cycle2(seq, n): > seq = iter(seq) > head = [next(seq) for i in range(n)] > for item in seq: > yield item > for item in head: > yield item Thanks, yeah, don't know what I was thinking :) Too much C work lately! ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Cycle around a sequence Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-08 01:10 +0000
Re: Cycle around a sequence Christoph Hansen <ch@radamanthys.de> - 2012-02-08 03:01 +0100
Re: Cycle around a sequence Neil Cerutti <neilc@norwich.edu> - 2012-02-08 14:25 +0000
Re: Cycle around a sequence Terry Reedy <tjreedy@udel.edu> - 2012-02-08 15:15 -0500
Re: Cycle around a sequence Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-08 22:47 +0000
Re: Cycle around a sequence Serhiy Storchaka <storchaka@gmail.com> - 2012-02-09 12:10 +0200
Re: Cycle around a sequence Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-09 03:55 +0000
Re: Cycle around a sequence Chris Angelico <rosuav@gmail.com> - 2012-02-09 15:16 +1100
Re: Cycle around a sequence Peter Otten <__peter__@web.de> - 2012-02-09 09:33 +0100
Re: Cycle around a sequence Chris Angelico <rosuav@gmail.com> - 2012-02-09 21:34 +1100
csiph-web