What's the Pythonic way to do this?

Phillip J. Eby pje at telecommunity.com
Sun Sep 12 11:24:57 EDT 2004


da_rosser at yahoo.com (Doug Rosser) wrote in message news:<e08cd05f.0409101235.50b1f8f3 at posting.google.com>...
> class Cycle(object):
> [snip]

    def cycle(inputList):
        while True:
            for item in inputList:
                yield item

Or, as others have pointed out, there's an itertools.cycle that does
the same thing, at least in Python 2.3 and up.



More information about the Python-list mailing list