On Thu, Jun 4, 2009 at 7:42 PM, Scott David
Danielsscott.dani...@acm.org wrote:
Brian Quinlan wrote:
This is from Python built from the py3k branch:
c = (lambda : i for i in range(11, 16))
for q in c:
... print(q())
...
11
12
13
14
15
# This is expected
c = (lambda : i
Michele Simionato wrote:
Yes, most functional languages have the concept of streams.
You can even define a stream-comprehension that looks like
Python generator comprehension but it is an essentially different
thing. See for instance
http://www.artima.com/weblogs/viewpost.jsp?thread=251159
I
In article mailman.1249.1244323524.8015.python-l...@python.org,
Terry Reedy tjre...@udel.edu wrote:
(1) Calling the first and rest methods 'car' and 'cdr' convinces me that
schemers really do not want scheme to be popular, but prefer it to
remain a small cult language.
What, you don't get a
In article 4a28903b.4020...@sweetapp.com,
Brian Quinlan br...@sweetapp.com wrote:
Scott David Daniels wrote:
[snipped]
When you evaluate a lambda expression, the default args are evaluated,
but the expression inside the lambda body is not. When you apply that
evaluated lambda expression,
In message mailman.1133.1244152009.8015.python-l...@python.org, Brian
Quinlan wrote:
c = (lambda : i for i in range(11, 16))
d = list(c)
for q in d:
...print(q())
...
15
15
15
15
15
Try
c = ((lambda i : lambda : i)(i) for i in range(11,
On Jun 5, 6:49 am, a...@pythoncraft.com (Aahz) wrote:
In article
05937a34-5490-4b31-9f07-a319b44dd...@r33g2000yqn.googlegroups.com,
Michele Simionato michele.simion...@gmail.com wrote:
Actually, in Scheme one would have to fight to define
a list comprehension (more in general loops)
On Jun 5, 6:49 am, a...@pythoncraft.com (Aahz) wrote:
In article
05937a34-5490-4b31-9f07-a319b44dd...@r33g2000yqn.googlegroups.com,
Michele Simionato michele.simion...@gmail.com wrote:
Actually, in Scheme one would have to fight to define
a list comprehension (more in general loops)
In message
78180b4c-68b2-4a0c-8594-50fb1ea2f...@c19g2000yqc.googlegroups.com, Michele
Simionato wrote:
The crux is in the behavior of the for loop:
in Python there is a single scope and the loop variable is
*mutated* at each iteration, whereas in Scheme (or Haskell or any
other functional
En Fri, 05 Jun 2009 01:49:15 -0300, Aahz a...@pythoncraft.com escribió:
In article
05937a34-5490-4b31-9f07-a319b44dd...@r33g2000yqn.googlegroups.com,
Michele Simionato michele.simion...@gmail.com wrote:
Actually, in Scheme one would have to fight to define
a list comprehension (more in
In article h0ahkb$he...@lust.ihug.co.nz,
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote:
In message
78180b4c-68b2-4a0c-8594-50fb1ea2f...@c19g2000yqc.googlegroups.com, Michele
Simionato wrote:
The crux is in the behavior of the for loop: in Python there is a
single scope and the
Ned Deily wrote:
In article 4a28903b.4020...@sweetapp.com,
Brian Quinlan br...@sweetapp.com wrote:
Scott David Daniels wrote:
[snipped]
When you evaluate a lambda expression, the default args are evaluated,
but the expression inside the lambda body is not. When you apply that
evaluated
Brian Quinlan wrote:
Sorry, I wasn't as precise as I should have been.
If you consider this example:
(expr for x in y)
I thought that every time that expr was evaluated, it would be done in
a new closure with x bound to the value of x at the time that the
closure was created.
Instead, a
On Jun 6, 12:06 am, Terry Reedy tjre...@udel.edu wrote:
Brian Quinlan wrote:
Sorry, I wasn't as precise as I should have been.
If you consider this example:
(expr for x in y)
I thought that every time that expr was evaluated, it would be done in
a new closure with x bound to the
This is from Python built from the py3k branch:
c = (lambda : i for i in range(11, 16))
for q in c:
... print(q())
...
11
12
13
14
15
# This is expected
c = (lambda : i for i in range(11, 16))
d = list(c)
for q in d:
... print(q())
...
15
15
15
15
15
# I was very surprised
Looking
En Thu, 04 Jun 2009 18:40:07 -0300, Brian Quinlan br...@sweetapp.com
escribió:
This is from Python built from the py3k branch:
It's not new; same thing happens with 2.x
A closure captures (part of) the enclosing namespace, so names are
resolved in that environment even after the
On Jun 4, 2:40 pm, Brian Quinlan br...@sweetapp.com wrote:
This is from Python built from the py3k branch:
c = (lambda : i for i in range(11, 16))
for q in c:
... print(q())
...
11
12
13
14
15
# This is expected
c = (lambda : i for i in range(11, 16))
d = list(c)
for
Gabriel Genellina wrote:
En Thu, 04 Jun 2009 18:40:07 -0300, Brian Quinlan br...@sweetapp.com
escribió:
This is from Python built from the py3k branch:
It's not new; same thing happens with 2.x
A closure captures (part of) the enclosing namespace, so names are
resolved in that environment
On Jun 5, 1:18 am, Carl Banks pavlovevide...@gmail.com wrote:
It's really the only sane way to handle it, odd though it may seem in
this narrow case. In Python nested functions have to be able to
reference the current value of a variable because of use cases like
this:
def func():
def
Carl Banks wrote:
snip
The way to handle the issue you are seeing is to create a new scope
with a variable the remains at the value you want to close upon:
create_const_function(value):
def func():
return value
c =create_const_function(i) for i in range(11, 16))
Or you can do it
In article 05937a34-5490-4b31-9f07-a319b44dd...@r33g2000yqn.googlegroups.com,
Michele Simionato michele.simion...@gmail.com wrote:
Actually, in Scheme one would have to fight to define
a list comprehension (more in general loops) working as
in Python: the natural definition works as the OP
20 matches
Mail list logo