[wxPython-users] Trouble using lambda to pass args to event function

Christopher Barker Chris.Barker at noaa.gov
Wed Nov 29 13:21:11 PST 2006


Peter Hansen wrote:
> Here's a one-line example of using it from something here:
> 
> self.Bind(wx.EVT_BUTTON, partial(self.OnOpenButton, index=i), button)

cool, but how is that any better than using lambda?

self.Bind(wx.EVT_BUTTON, lambda event, index=i: self.OnOpenButton(event, 
index), button)

I guess it's slightly less verbose.

(I'd do: button.Bind instead, though that has nothing to do with the 
topic at hand)

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list