Other amazing Python answers by the same guy:<p>What is a metaclass in Python - <a href="http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python/6581949#6581949" rel="nofollow">http://stackoverflow.com/questions/100003/what-is-a-metaclas...</a><p>Understanding Python decorators - <a href="http://stackoverflow.com/questions/739654/understanding-python-decorators/1594484#1594484" rel="nofollow">http://stackoverflow.com/questions/739654/understanding-pyth...</a>
Hi guys, I'm the autor of the answers.<p>Thanks for the feedback. Because of comments like these, I decided to spend more time at training people for a living, and I'm loving it.<p>So don't underestimate the power of web comments, it can literally change the way people live.
A helpful hint on the name: Yield should be read like "Yields" as in "returns" or "produces".<p>Not Yield as in the common multithreading command to allow another thread to run.<p>PS. Anyone know why they chose such a confusing name?
What I find weird about the yield keyword is that it seems to effect the execution of code that comes before the statement, causing it not to execute until later.<p>For example:<p><pre><code> def createGenerator():
print "aaa"
mygen = createGenerator()
</code></pre>
outputs:<p><i>aaa</i><p>Whereas<p><pre><code> def createGenerator():
print "aaa"
yield
mygen = createGenerator()
</code></pre>
Outputs nothing.