Skip to content

Instantly share code, notes, and snippets.

@briandailey
Created January 3, 2013 13:55
Show Gist options
  • Select an option

  • Save briandailey/4443624 to your computer and use it in GitHub Desktop.

Select an option

Save briandailey/4443624 to your computer and use it in GitHub Desktop.
cycling an uninstantiated class variable
>>> from itertools import cycle
>>> class Foo(object):
... c = cycle(['1', '2'])
...
>>> Foo.c
<itertools.cycle object at 0x1004690e0>
>>> Foo.c.next()
'1'
>>> Foo.c.next()
'2'
>>> Foo.c.next()
'1'
>>> Foo.c.next()
'2'
>>> Foo.c.next()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment