Music knowledge representation

Mark Tolonen M8R-yfto6h at mailinator.com
Sun Sep 28 15:20:55 EDT 2008


"Mr.SpOOn" <mr.spoon21 at gmail.com> wrote in message 
news:mailman.1633.1222628890.3487.python-list at python.org...
> On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady
> <castironpi at gmail.com> wrote:
>
>> Here is a link to someone else's design they asked about on the
>> newsgroup a couple weeks ago.
>>
>> http://groups.google.com/group/comp.lang.python/browse_thread/thread/ecffaa827984866d/921cba3084b984dc?lnk=st&q=sharpnote#921cba3084b984dc
>
> :D
> It's always me.
>
> I think my question is more specific. I need some sort of cycle.
>
> So if I have a list with A, B, C, D, when I iter over it I need to get
> an A after the D.

Check out itertools.cycle:

>>> x=itertools.cycle('ABCDEFG')
>>> x.next()
'A'
>>> x.next()
'B'
>>> x.next()
'C'
>>> x.next()
'D'
>>> x.next()
'E'
>>> x.next()
'F'
>>> x.next()
'G'
>>> x.next()
'A'
>>> x.next()
'B'

-Mark




More information about the Python-list mailing list