[Tutor] How to pass multiple variables in callback function?
Alan Gauld
alan.gauld at btinternet.com
Wed Dec 6 00:26:22 CET 2006
"Asrarahmed Kadri" <ajkadri at googlemail.com> wrote
> I mean to say that suppose I have two lists, and I want to pass them
> to the
> event handling function. Is that possible using bind?
Not answering your question directly but you can do
it with a lambda expression.
def myfunc(l1,l2):
# the func I want to use
foo = lambda p1=list1, p2=list2: myfunc(p1,p2)
bind(e,foo)
or just
bind(e,lambda p1=list1, p2=list2: myfunc(p1,p2))
Obviously(?) list1 and list2 need to be in the same scope as
the lambda expression!
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list