Using lambda [was Re: Article of interest: Python pros/cons for theenterprise]

Terry Reedy tjreedy at udel.edu
Sun Feb 24 21:13:08 EST 2008


"Steven D'Aprano" <steve at REMOVE-THIS-cybersource.com.au> wrote in message 
news:13s26luietu512c at corp.supernews.com...
| On Sat, 23 Feb 2008 19:35:30 -0800, Jeff Schwab wrote:
|
| > Every time somebody uses
| > lambda here, they seem to get a bunch "why are you using lambda?"
| > responses.

I think you are overgeneralizing ;-)
I use 'em.

| Not from me.
|
| I even use "named anonymous functions" *cough* by assigning lambda
| functions to names:
|
| foo = lambda x: x+1

Even though I consider the above to be clearly inferior to

def foo(x): return x+1

since the latter names the function 'foo' instead of the generic 
'<lambda>'.
The only other situation in which I would critisize lambda usage are 
multi-line (or super-long-line) monstrousities that are not intentionally 
'obfuscated Python'.

tjr








More information about the Python-list mailing list