"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > a temporary factory function should be sufficient: > > def digit(label, x, y): > def callback(): > # print "BUTTON PRESS", label # debug! > user_pressed(int(label)) > Button(label=label, command=callback).grid(column=x, row=y)
Looking at the calculator program I wrote a while back (one of my first Python programs, written just to play with tkinter), I see that I actually did something like that for the buttons. However, it also contained (in the other order): unops = {'sqrt': math.sqrt, 'sin': math.sin, 'cos': math.cos, 'tan': math.tan, 'ln': math.log, 'log': lambda x: math.log(x)/math.log(10), 'clr x': lambda x: 0 } binops = {'+': (lambda x,y: x+y), '-': (lambda x,y: x-y), '*': (lambda x,y: x*y), '/': (lambda x,y: x/y), '**': (lambda x,y: x**y) } How would you refactor that, with no lambda? -- http://mail.python.org/mailman/listinfo/python-list