Ethan Furman wrote:
Erik Bernoth wrote:
Hi List,
look at the following code:
def evens():
# iterator returning even numbers
i = 0
while True:
yield i
i += 2
# now get all the even numbers up to 15
L = [n for n in evens() if n < 15]
Isn't it strange, that this cod
Erik Bernoth wrote:
Hi List,
look at the following code:
def evens():
# iterator returning even numbers
i = 0
while True:
yield i
i += 2
# now get all the even numbers up to 15
L = [n for n in evens() if n < 15]
Isn't it strange, that this code runs (in a lazy lang
Antoine Pitrou wrote:
Erik Bernoth googlemail.com> writes:
Isn't it strange, that this code runs (in a lazy language) for eternity?
Python is a not a lazy language.
`and` and `or` are particular, they are language constructs (*), not operators,
that's why they can decide whether or
Erik Bernoth googlemail.com> writes:
>
> Isn't it strange, that this code runs (in a lazy language) for eternity?
Python is a not a lazy language.
`and` and `or` are particular, they are language constructs (*), not operators,
that's why they can decide whether or not to evaluate their second te
Erik Bernoth wrote:
Hi List,
look at the following code:
def evens():
# iterator returning even numbers
i = 0
while True:
yield i
i += 2
# now get all the even numbers up to 15
L = [n for n in evens() if n < 15]
Isn't it strange, that this code runs (in a lazy lang
2009/8/13 Erik Bernoth :
> 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,
Erik Bernoth wrote:
Hi List,
look at the following code:
def evens():
# iterator returning even numbers
i = 0
while True:
yield i
i += 2
# now get all the even numbers up to 15
L = [n for n in evens() if n < 15]
Isn't it strange, that this code runs (in a lazy lang
Hi List,
look at the following code:
def evens():
# iterator returning even numbers
i = 0
while True:
yield i
i += 2
# now get all the even numbers up to 15
L = [n for n in evens() if n < 15]
Isn't it strange, that this code runs (in a lazy language) for eternity? I