title: lambda function don't closure the parameter in Python?
body: <p>Code talks more:</p>
  
  <pre><code>
  from pprint import pprint
  
  li = []
  
  for i in range(5):
          li.append(lambda : pprint(i))
  
  for k in li:
          k()
  </code></pre>
  
  <p>yield:</p>
  
  <pre>
  4
  4
  4
  4
  4
  </pre>
  
  <p>why not</p>
  
  <pre>
  0
  1
  2
  3
  4
  </pre>
  
  <p>??</p>
  
  <p>Thanks.</p>
  
  <p>P.S. If I write the complete decorator, it works as expected:</p>
  
  <pre><code>
  
  from pprint import pprint
  
  li = []
  
  #for i in range(5):
          #li.append(lambda : pprint(i))
  
  def closure(i):
          def _func():
                  pprint(i)
          return _func
  
  for i in range(5):
          li.append(closure(i))
  
  for k in li:
          k()
  </code></pre>