Steve,
Hey, thanks. I'll try that.
Horace
In article <[EMAIL PROTECTED]>,
Steven Bethard <[EMAIL PROTECTED]> wrote:
> Horace Enea wrote:
> > My example wasn't very good. Here's another try:
> >
> > def foo():
> >yield 1
> >yield 2
> >yield 3
> >
> > f = foo()
> > f.next()
> > 1
>
Horace Enea wrote:
> My example wasn't very good. Here's another try:
>
> def foo():
>yield 1
>yield 2
>yield 3
>
> f = foo()
> f.next()
> 1
>
> g=copy(f) # copy the generator after an iteration
>
> f.next()
> 2
> f.next()
> 3
>
> g.next()
> 2
>
> I want to copy the generat
My example wasn't very good. Here's another try:
def foo():
yield 1
yield 2
yield 3
f = foo()
f.next()
1
g=copy(f) # copy the generator after an iteration
f.next()
2
f.next()
3
g.next()
2
I want to copy the generator's state after one or more iterations.
In article <[EMAI
Why not just do this:
>>> def foo():
... yield 1
... yield 2
... yield 3
...
>>> f = foo()
>>> g = foo()
>>> f.next()
1
>>> f.next()
2
>>> f.next()
3
>>> g.next()
1
>>> g.next()
2
>>> g.next()
3
--
http://mail.python.org/mailman/listinfo/python-list
Does anyone have code to copy a generator?
Here is what I'd like to do:
def foo():
yield 1
yield 2
yield 3
f = foo()
g = copy(foo)
print f.next()
1
print f.next()
2
print g.next()
1
Thanks,
Horace
--
http://mail.python.org/mailman/listinfo/python-list