copying generatrors

Horace Enea hjenea at earthlink.net
Wed Jun 6 01:10:41 CEST 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