Let's Talk About Lambda Functions!
John Roth
johnroth at ameritech.net
Tue Aug 6 09:07:27 EDT 2002
"Miki Tebeka" <tebeka at cs.bgu.ac.il> wrote in message
news:33803989.0208060021.183da5b0 at posting.google.com...
> Hello Brit,
>
> > So I know what lambda functions are, they're syntax and how they're
used.
> > However I'm not sure *why* one would use a lambda function. What's
the
> > advantage that they offer over a regular function?
>
> Warning: I've bee a Scheme believer before I've converted to Python
> :-)
>
> Sometime lambda functions yeild more (IMO) elegant solution that is
> easier to read and understand.
> One example is success/fail continuations.
An even more appropo example is with Tkinter. There are
many things in that package for which you absolutely have to have
trivial callback functions. Either you wind up implementing lots
of real simple two or three line functions (for which you have
to invent names) or you use lambdas.
One of the real difficulties here is that Tkinter doesn't always
give you what you need to implement a more general callback
that services multiple widgets.
If you want to call that a problem with Tkinter, I'm not going
to argue.
John Roth
More information about the Python-list
mailing list