Question on lambdas

memilanuk memilanuk at gmail.com
Mon Dec 8 18:43:18 EST 2014


So... I was browsing some questions on reddit, and one of them involved 
tkinter and lambdas.  Managed to help the person out, but in the process 
ended up with more questions of my own :/

My basic confusion revolves around this: in one instance I see things 
like the following:

R1 = tk.Radiobutton(root, text='A', value=100, variable=var,
                     command=lambda: update_label2('A', 100))

and in another example I see things like this:

class MyText(Text):
     def __init__(self, master, **kw):
         apply(Text.__init__, (self, master), kw)
         self.bind("<Return>", lambda e: "break")


What I'm having trouble finding a concrete answer to is the difference 
between:

lambda: some_func

lambda e: some_func

lambda e=e: some_func

Any help would be greatly appreciated.

TIA,

Monte

-- 
Shiny!  Let's be bad guys.

Reach me @ memilanuk (at) gmail dot com




More information about the Python-list mailing list