Lambda going out of fashion

Stephen Thorne stephen.thorne at gmail.com
Thu Dec 23 05:13:28 CET 2004


Hi guys,

I'm a little worried about the expected disappearance of lambda in
python3000. I've had my brain badly broken by functional programming
in the past, and I would hate to see things suddenly become harder
than they need to be.

An example of what I mean is a quick script I wrote for doing certain
actions based on a regexp, which I will simlify in this instance to
make the pertanant points more relevent.

{
 'one': lambda x:x.blat(),
 'two': lambda x:x.blah(),
}.get(someValue, lambda x:0)(someOtherValue)

The alternatives to this, reletively simple pattern, which is a rough
parallel to the 'switch' statement in C, involve creating named
functions, and remove the code from the context it is to be called
from (my major gripe).

So, the questions I am asking are: 
Is this okay with everyone? 
Does anyone else feel that lambda is useful in this kind of context? 
Are there alternatives I have not considered?

merrily-yr's
Stephen.



More information about the Python-list mailing list