On 11/26/06, Robert Kern <[EMAIL PROTECTED]> wrote:
The only thing that the last line does is *create* a new generator object. You need to actually iterate over it and yield its values. E.g. In [2]: def test_gen(x): ...: yield x ...: x -= 1 ...: if x != 0: ...: for y in test_gen(x): ...: yield y ...: ...: In [3]: list(test_gen(3)) Out[3]: [3, 2, 1]
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. Timothy
-- http://mail.python.org/mailman/listinfo/python-list