D
Dan
So, I think I understand what python's scoping is doing in the
following situation:
<function <lambda> at 0x00BECA70>, <function <lambda> at 0x00C1EBF0>,
<function <lambda> at 0x00C1EE30>, <function <lambda> at 0x00C228F0>,
But, I'm wondering what is the easiest (and/or most pythonic) way to
get the behavior I want? (If you haven't guessed, I want a list of (no
parameter) functions, each of which returns its index in the list.)
-Dan
following situation:
[<function <lambda> at 0x00BEC070>, <function <lambda> at 0x00BEC7F0>,x = [ lambda: ind for ind in range(10) ]
x
<function <lambda> at 0x00BECA70>, <function <lambda> at 0x00C1EBF0>,
<function <lambda> at 0x00C1EE30>, <function <lambda> at 0x00C228F0>,
[/QUOTE][QUOTE= said:x[0]() 9
x[5]() 9
x[9]() 9
ind 9
ind = 2
x[0]() 2
But, I'm wondering what is the easiest (and/or most pythonic) way to
get the behavior I want? (If you haven't guessed, I want a list of (no
parameter) functions, each of which returns its index in the list.)
-Dan