title: Automatic binding using lambdas inside a loop
body: <p>I am currently trying to create a loop that would bind event-action couples in a dict.
  The callback function simply calls the action function and prints the parameters.</p>
  
  <pre><code>for binding, action in self.keyMap.revMap.items() :
          print binding, action
          self.top.bind(binding,
                        lambda event : self.callback(event, self.actionRep.__class__.__dict__[action]))
  
      print self.top.bind()
  </code></pre>
  
  <p>At the binding, I get these logs :</p>
  
  <pre><code>&lt;Escape&gt; toggleMenu -------------generated by the line "print binding, action"
  &lt;Return&gt; toggleChat -------------generated by the line "print binding, action"
  ('&lt;Key-Return&gt;', '&lt;Key-Escape&gt;', '&lt;Key&gt;') ---generated by the line "print self.top.bind()"
  </code></pre>
  
  <p>The event-action couples are correct.
  However, when the events occur, I have this :</p>
  
  <pre><code>&lt;Tkinter.Event instance at 0x0000000002BB3988&gt; &lt;function toggleChat at 0x0000000002B60AC8&gt;
  &lt;Tkinter.Event instance at 0x0000000002BB3948&gt; &lt;function toggleChat at 0x0000000002B60AC8&gt;
  </code></pre>
  
  <p>that is, both the escape and the return event seem to be bound to toggleChat...</p>
  
  <p>I have little experience of lambda expressions, but I would expect that a new nameless function is created for each of the loops. Am I wrong there ? If not, where could the problem be ?</p>
  
  <p>Thanks in advance for insights.</p>