Event Binding and Variable Passing
Gordon McMillan
gmcm at hypernet.com
Sat Jul 1 15:48:02 EDT 2000
[posted & mailed]
Cameron subtly baited:
In article <39567A5A.5B692C5D at pacbell.net>,
Bruce Wolk <{HYPERLINK "http://www.deja.com/[ST_rn=ps]/profile.xp?author=bawolk at ucdavis.edu&ST=PS"}bawolk at ucdavis.edu> wrote:
>You need to use a lamda expression.
>
>def fun(x):
> print x
>b.bind('<Button-1>', lambda event, b=x: fun(b))
.
.
.
Can one of the old(er?)-timers help me with this?
There's a sect (claiming the Guido among its sym-
pathizers) that deprecates lambdas for Python, no?
But their reasons (very abstractly, that object-
oriented metaprogramming gives more than enough
goodies, making lambdas essentially redundant) do
*not* apply for communication with the event- and
binding-mechanisms adapted from Tcl, true? The
conclusion would be, then, that Tkinter forces a
fundamental need for lambdas.
Well, my version of IDLE contains all of 9 lambdas, only 3 of which
are used with Tkinter. So obviously Guido is no big fan of lambda,
but neither does he abstain from its use.
However, the fact that that much Tkinter code uses only 3 lambdas
belies your assertion.
Of course there are a multiplicity of sects within Python, sharing little
more than a common shortage of virgins...
- Gordon
More information about the Python-list
mailing list