Re: cloning generator iterators

2006-08-20 Thread Michael
Bernhard Mulder wrote: > [ attempt to clone/fork a generator ] You can do this, but you can't pickle the results. (If you want pickling, use Stackless - I've not tried pickling generators in stackless because I don't use stackless, but it looks pretty clear you can pickle them there) > Question

Re: cloning generator iterators

2006-08-19 Thread Bernhard Mulder
Oops. Got the indentation wrong. Here is the corrected version: def generator(self): while True: while True: if (yield 1): if (yield 1): break self.n = 2 while (yield self.n):

cloning generator iterators

2006-08-19 Thread Bernhard Mulder
I have something like the following (using Python 2.5 syntax): class adapt(object): def __init__(self): self.iterator = self.generator() self.n = 0 def generator(self): while True: while True: if (yield 1): if (yield 1