On 8/27/2011 9:19 PM, Terry Reedy wrote:
On 8/27/2011 11:45 PM, John O'Hagan wrote:
Somewhat apropos of the recent function principle thread, I was
recently surprised by this:
funcs=[]
for n in range(3):
def f():
return n
funcs.append(f)
The last expression, IMO surprisingly, is [2,2,2],
On 28/08/11 05:45, John O'Hagan wrote:
Somewhat apropos of the recent function principle thread, I was recently
surprised by this:
funcs=[]
for n in range(3):
def f():
return n
funcs.append(f)
[i() for i in funcs]
The last expression, IMO surprisingly, is [2,2,2],
On 8/28/2011 10:04 AM, Thomas Jollans wrote:
This does not do what you'd like it to do. But let's assume that, it
did, that Python, when encountering a function definition inside a
function, froze the values of nonlocal variables used in the new
function, from the point of view of that function
On Saturday, August 27, 2011 8:45:05 PM UTC-7, John O#39;Hagan wrote:
Somewhat apropos of the recent function principle thread, I was recently
surprised by this:
funcs=[]
for n in range(3):
def f():
return n
funcs.append(f)
[i() for i in funcs]
The last expression,
Somewhat apropos of the recent function principle thread, I was recently
surprised by this:
funcs=[]
for n in range(3):
def f():
return n
funcs.append(f)
[i() for i in funcs]
The last expression, IMO surprisingly, is [2,2,2], not [0,1,2]. Google tells me
I'm not the only one
On 8/27/2011 11:45 PM, John O'Hagan wrote:
Somewhat apropos of the recent function principle thread, I was recently
surprised by this:
funcs=[]
for n in range(3):
def f():
return n
funcs.append(f)
The last expression, IMO surprisingly, is [2,2,2], not [0,1,2]. Google
On Sun, 28 Aug 2011 00:19:07 -0400
Terry Reedy tjre...@udel.edu wrote:
On 8/27/2011 11:45 PM, John O'Hagan wrote:
Somewhat apropos of the recent function principle thread, I was recently
surprised by this:
funcs=[]
for n in range(3):
def f():
return n