469,929 Members | 1,742 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

About lambda.

Some c++ guru said c++ is hard to learn but easy to
use. Is python easy for both aspect? I found lot's of
confused in coding.

from Tkinter import *

def on_click(m):
print m
def lamb_on_click(m):
return lambda : on_click(m)
root = Tk()
btns = ['0', '1', '2', '3']
for n in btns:
b = Button(root, text=n, command=lamb_on_click(n))


b = Button(root, text=n, command=lambda x=n:
click(x)) #Ok!

The code above works well too, but follow is NOT! WHY?

b = Button(root, text=n, command=lambda :

Whichever button be clicked, this only print '3'.

Keyword 'lambda' is just like a macro in c or templete
in c++ or not?

Do you Yahoo!?
Declare Yourself - Register online to vote today!
Jul 18 '05 #1
1 1550
>>>>> "Xin" == Xin Wang <xe*****@yahoo.com> writes:

Xin> Some c++ guru said c++ is hard to learn but easy to use. Is

I would question such a guru. There is nothing "easy to use" about
C++. Or perhaps the Guru hadn't tried any other modern language apart
from C.

Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
28 posts views Thread by David MacQuigg | last post: by
53 posts views Thread by Oliver Fromme | last post: by
1 post views Thread by Xin Wang | last post: by
63 posts views Thread by Stephen Thorne | last post: by
23 posts views Thread by Kaz Kylheku | last post: by
16 posts views Thread by nephish | last post: by
21 posts views Thread by globalrev | last post: by
1 post views Thread by Tim H | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.