2009/8/13 Erik Bernoth <erik.bern...@googlemail.com>:
> after 14 it is not nessesary to evaluate evens() any further.

How does Python know this? I.e. how does it know that evens() will
always yield things in ascending order? For example, I could write an
iterator like this:

def my_iter():
    for i in [0,2,4,6,8,10,12,14,16,18,1,3,5]:
        yield i

Now, imagine I do [i for i in my_iter() if i < 15]. If you quit
iterating after `i' becomes 16, you'll miss the valid numbers 1, 3, 5
at the end of the list!

-- 
-David
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to