On 11/26/06, <b class="gmail_sendername">Robert Kern</b> <<a href="mailto:robert.kern@gmail.com">robert.kern@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>The only thing that the last line does is *create* a new generator object. You<br>need to actually iterate over it and yield its values. E.g.<br><br><br>In [2]: def test_gen(x):<br>   ...:     yield x<br>   ...:     x -= 1
<br>   ...:     if x != 0:<br>   ...:         for y in test_gen(x):<br>   ...:             yield y<br>   ...:<br>   ...:<br><br>In [3]: list(test_gen(3))<br>Out[3]: [3, 2, 1]</blockquote><div><br> <br>Ha-HA, that makes perfect sense I guess. Though in my opinion the definition makes the code a bit harder to read. Thanks for the explanation.
<br><br>Timothy<br></div></div>