Calling a generator multiple times

Courageous jkraska at san.rr.com
Mon Dec 10 01:11:17 EST 2001


>    In practice (how you think about them), generators *are*
>    functions, but with the twist that they're resumable.

>This could perhaps do with some elaboration.

Maybe more like a revision. Thinking about them as functions
isn't right. When you call a function, it's code executes.
When you call a generator, something else executes which prepares
the code the programmer wrote for execution.

While people will get to used to it just fine, let's just say
I happen to agree with the listing of this as a "wart".

>It's at *that* point that some of us get the very
>strong feeling that there is something wrong with
>declaring a generator just like a function. Telling
>us to go read the discussions or the PEP does
>nothing to dispel that feeling. We've been there,
>and have come to a different conclusion.

Word.

C//




More information about the Python-list mailing list