Evaluating a list of python lambda functions only evaluates the last list element
<p>I have a list of lambda functions I want to evaluate in order. I'm not sure why, but only the last function gets evaluated. Example below:</p>

<pre><code>  &gt;&gt;&gt; def f(x,z):
  ...     print "x=",x,", z=",z
  ... 
  &gt;&gt;&gt; 
  &gt;&gt;&gt; g = lambda x : f(x,13)
  &gt;&gt;&gt; g(2)
  x= 2 , z= 13    # As expected
  &gt;&gt;&gt; 
  &gt;&gt;&gt; lst=[]
  &gt;&gt;&gt; 
  &gt;&gt;&gt; for i in range(0,5): 
  ...    lst.append(lambda x: f(x,i))
  ... 
  &gt;&gt;&gt; print lst
  [&lt;function &lt;lambda&gt; at 0x10341e2a8&gt;, &lt;function &lt;lambda&gt; at 0x10341e398&gt;, &lt;function &lt;lambda&gt; at 0x10341e410&gt;, &lt;function &lt;lambda&gt; at 0x10341e488&gt;, &lt;function &lt;lambda&gt; at 0x10341e500&gt;]
  &gt;&gt;&gt; 
  &gt;&gt;&gt; for fn in lst:
  ...   fn(3)
  ... 
  x= 3 , z= 4 # z should be 0
  x= 3 , z= 4 # z should be 1
  x= 3 , z= 4 # z should be 2
  x= 3 , z= 4 # z should be 3
  x= 3 , z= 4 # as expected.
</code></pre>

<p>I think only the last one is getting executed, but not the others. Any ideas? Thanks!</p>
