copying generatrors

Horace Enea hjenea at earthlink.net
Tue Jun 5 19:10:41 EDT 2007


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



More information about the Python-list mailing list