En Mon, 02 Mar 2009 06:48:02 -0200, Lie Ryan <lie.1...@gmail.com> escribió:
Gabriel Genellina wrote:
En Sun, 01 Mar 2009 15:51:07 -0200, Chris Rebert <c...@rebertia.com>
escribió:
On Sun, Mar 1, 2009 at 8:54 AM, Gabriel Genellina
<gagsl-...@yahoo.com.ar> wrote:
En Sun, 01 Mar 2009 13:20:28 -0200, John O'Hagan
<resea...@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.

How about creating something like itertools.tee() that will save and
dump items as necessary. The "new tee" (let's call it tea) would return
several generators that all will refer to a common "tea" object. The
common tea object will keep track of which items has been collected by
each generators and generate new items as necessary. If an item has
already been collected by all generators, that item will be dumped.

That's exactly what itertools.tee does! Or I'm missing something?

--
Gabriel Genellina

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

Reply via email to