Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feed.xsnews.nl!border-1.ams.xsnews.nl!xlned.com!feeder7.xlned.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'reedy': 0.16; 'header:In-Reply-To:1': 0.22; 'yield': 0.29; 'header:User- Agent:1': 0.33; 'header:X-Complaints-To:1': 0.34; 'to:addr:python- list': 0.35; 'received:org': 0.36; '8bit%:86': 0.37; 'to:addr:python.org': 0.40; 'skip:\xd0 20': 0.77; 'received:88.154': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: Cycle around a sequence Date: Thu, 09 Feb 2012 12:10:41 +0200 References: <9pfeutFtjiU2@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 88.154.142.227 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20120130 Thunderbird/10.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328782266 news.xs4all.nl 6864 [2001:888:2000:d::a6]:34250 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20062 08.02.12 22:15, Terry Reedy написав(ла): > To make a repeating rotator is only a slight adjustment: > > k = n - len(seq) > while True: > i = k > while i < n: > yield seq[i] > i += 1 for i in range(n, len(seq)): yield seq[i] while True: for x in seq: yield x