Securing a future for anonymous functions in Python

Nick Coghlan ncoghlan at iinet.net.au
Fri Dec 31 03:38:24 CET 2004


Batista, Facundo wrote:
> [Nick Coghlan]
> 
> #- I just don't understand why people complain so much about
> #- the restriction to a
> #- single expression in lambdas, yet there is nary a peep about
> #- the same
> #- restriction for generator expressions and list comprehensions.
> 
> What *I* don't understand (and it could perfectly be plain ignorance, as 
> never studied languages or computer sciences) is why anonymous functions 
> are so important.

Speaking for myself, I find lazy evaluation of arguments is impractical without 
them. Defining 2 or 3 named functions in order to make a single function call 
seems rather unnecessarily verbose. I don't need to use lazy evaluation very 
often, but when I do use it, it is generally because other approaches would be 
much more complicated (or significantly less efficient).

This usage pattern is also why I do not find the restriction to a single 
expression a problem in practice - since I'm merely delaying the evaluation of 
what I would have supplied as a function argument anyway, I'm already working 
with an expression.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list