Returning values from a lambda

John McMonagle johnmc at
Fri Nov 16 01:36:06 CET 2001

I wish to return values from a lambda function which is bound to the
Tkinter button command option.  For example,

def operations(a,b):
  return a+b, a*b

from Tkinter import *
root = Tk()
btn = Button(root, text='Press Me', command=lambda a=2, b=5: operations(a,b))

How do I assign the returned values to variables, say x,y ?  I guess I
want to do something like,

lambda a=2, b=5: x,y=operations(a,b)

but this gives me the error:

SyntaxError: can't assign to lambda

Is this possible ?

I'm using RedHat 7.0, python 1.5.2




More information about the Python-list mailing list