My Generator Paradox!

vbgunz vbgunz at gmail.com
Sat Mar 18 02:21:41 CET 2006


OK. I hope my understanding of the yield keyword and generators in a
general sense are now better understood. When a generator function is
assigned to an identifier, no code is executed and a generator is
immediately returned. When the next() method is called on the new
generator, code from top to bottom executes within the generator until
it reaches it's first yield. Many yields can appear within one
generator. When this is the case a next method call will execute code
from yield to yield. Code that appears in a loop after a yield keyword
is executed on the next() method call.

I hope I got it right. I love you guys for your patience and examples.
It is greatly appreciated and means very much to me! Thank you fellas!




More information about the Python-list mailing list