Calling a generator multiple times

Courageous jkraska at san.rr.com
Fri Dec 7 12:33:52 EST 2001


>That would reduce the power of generators in Python.  There would be no
>way to create a generator without starting it.

I don't think that's necessarily a bad thing, but what I feel
firmly about is that the current semantics versus syntax of
generators in python is obviously wrong.

Just about anything would be better, up to and including the
use of additional keywords. I simply feel strongly that as
long as a generator masquerades as a method, it ought to
behave like one, and that should be its default behavior.

If one wanted to create but not start, one might use "generate,"
e.g.:

f = generate g()
f()
f()
f()

Without "generate," you'd get invocation and generation behavior
at the same time.

C//




More information about the Python-list mailing list