En Wed, 14 Feb 2007 14:04:17 -0300, Andy Dingley <[EMAIL PROTECTED]>  
escribió:

> I still don't understand what a lambda is _for_ in Python. I know what
> they are, I know what the alternatives are, but I still haven't found
> an instance where it permits something novel to be done that couldn't
> be done otherwise (if maybe not so neatly).

A lambda is a shorthand for a simple anonymous function. Any lambda can be  
written as a function:

lambda args: expression

is the same as:

def __anonymous(args): return expression

(but the inverse is not true; lambda only allows a single expression in  
the function body).

Except for easy event binding in some GUIs, deferred argument evaluation,  
and maybe some other case, the're not used much anyway. Prior common usage  
with map and filter can be replaced by list comprehensions (a lot more  
clear, and perhaps as fast - any benchmark?)

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to