Let's Talk About Lambda Functions!

Chris Liechti cliechti at gmx.net
Fri Jul 26 14:44:00 EDT 2002


"Britt A. Green" <python at experimentzero.org> wrote in 
news:mailman.1027705851.8443.python-list at python.org:

> 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.

Guido may have asked himself similar questions, considering the note on the 
OSCON and EuroPython slides ;-)

> What's the
> advantage that they offer over a regular function?

you can define a lambda in an expression, while a "def" is a statement.
and that's probably all there it is. (lambdas have some constraints as they 
can only be expressions, but thats a detail)

cause' lambdas are expresions, they are useful when writing functional 
style programs.

map(lambda x,y:x+y, range(3), [7,8,5])

chris
-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list