title: Anonymous callback functions in Python 2.7.5?
body: <p>I'm trying to decouple GUI and Logic in a wxPython application using python 2.7.5. Since wxPython uses event binding I thought I'd extend this approach. Summarizing my code:</p>
  
  <p>GUI.py</p>
  
  <pre><code>class MainInterface():
      def __SetupControlPanel(self, controlPanel):
          self.DoSomethingButton = wx.Button(controlPanel, wx.ID_ANY, "Do something")
  
      def BindCallback_DoSomething(self, callback):
          self.frame.Bind(wx.EVT_BUTTON, callback, self.DoSomethingButton)
  </code></pre>
  
  <p>main.py</p>
  
  <pre><code>def DoSomething(event):
      someLogicClass.DoSomething()
  
  interface.BindEvent_DoSomething(DoSomething)
  </code></pre>
  
  <p>This decouples the two parts of the application nicely, but I don't like the way I have to define a separate function in main.py for every callback, as it usually just calls a single logic function. From a JS background, I'm used to being able to use an anonymous function. I'd imagine something like this would make my code somewhat more compact:</p>
  
  <pre><code>interface.BindEvent_DoSomething(def (event):
      someLogicClass.DoSomething()
  )
  </code></pre>
  
  <p>Is there any way to achieve such syntax in Python?</p>