PEP 255: Simple Generators

Tim Peters tim.one at home.com
Sun Jun 17 17:48:20 EDT 2001


[Robin Becker]
> so the implication is that the state can't be got at explicitly and I
> have to redefine the generator function part of the iterator to reset
> it? can one copy a generator-iterator?

Generator-iterators conform to the iterator protocol, and the latter has
only a .next() method:  no notion of reset, no notion of copy.  PEP 255
doesn't go beyond that.  Of course you can do, e.g.,

g1 = some_generator(x, y, z)
g2 = some_generator(x, y, z)
...

to get multiple independent generator-iterators.





More information about the Python-list mailing list