Iterator class to allow self-restarting generator expressions?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Sun Mar 1 13:08:04 EST 2009
En Sun, 01 Mar 2009 15:51:07 -0200, Chris Rebert <clp2 at rebertia.com>
escribió:
> On Sun, Mar 1, 2009 at 8:54 AM, Gabriel Genellina
> <gagsl-py2 at yahoo.com.ar> wrote:
>> En Sun, 01 Mar 2009 13:20:28 -0200, John O'Hagan
>> <research at johnohagan.com>
>> escribió:
>>
>>> 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.
>> I'm afraid you can't do that. There is no way of "cloning" a generator:
>
> Really? What about itertools.tee()? Sounds like it'd do the job,
> albeit with some caveats.
> http://docs.python.org/library/itertools.html#itertools.tee
It doesn't clone the generator, it just stores the generated objects in a
temporary array to be re-yielded later.
--
Gabriel Genellina
More information about the Python-list
mailing list