Let's Talk About Lambda Functions!

John Roth johnroth at ameritech.net
Fri Jul 26 15:59:01 EDT 2002


"Britt A. Green" <python at experimentzero.org> wrote in message
news:mailman.1027705851.8443.python-list at python.org...
> So I know what lambda functions are, their 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?

They let you put short, one-time functions inline. In some
environments (Tkinter comes immediately to mind) there
are lots of places where short, one-line functions are useful.
Putting a short, one-time function inline aids readability,
(at least for people who regard lambdas as readable.)

IMO, if the function is of any significant length, or if it
duplicates functionality from elsewhere, it should be
named and written separately.

John Roth





More information about the Python-list mailing list