"John O'Hagan" <resea...@johnohagan.com> wrote in message news:200903011520.29405.resea...@johnohagan.com...
Inspired by some recent threads here about using classes to extend the
behaviour of iterators, I'm trying to replace some some top-level functions
aimed at doing such things with a class.

So far it's got a test for emptiness, a non-consuming peek-ahead method, and
an extended next() which can return slices as well as the normal mode, but
one thing I'm having a little trouble with is getting generator expressions
to restart when exhausted. This code works for generator functions:

[snip code]

The Python help shows the Python-equivalent code (or go to the source) for things like itertools.islice and itertools.icycle, which sound like what you are re-implementing. It looks like to handle generators icycle saves the items as they are generated in another list, then uses the list to generate successive iterations.

-Mark

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to