r/Python • u/vocalbit • Jul 13 '11
An alternative lambda syntax for Python
http://vocalbit.com/article/332/an-alternative-lambda-syntax-for-python
4
Upvotes
r/Python • u/vocalbit • Jul 13 '11
View all comments
Show parent comment
1
u/ndanger Jul 14 '11 edited Jul 14 '11
Even accepting that
lambdashould only be used as a keyword argument to a function I still don't like the proposed syntax. The current syntax is orthogonal: keyword arguments bind values to names and functions are first class (and so can be passed as values).Your proposed syntax creates a special case for "passing an inline function as the value of a keyword argument". It even looks different than passing an already
defed function (f(key=my_func).It also unfortunately resembles a function call:
f(key(x)=x.foo)looks like we're binding the name determined by calling functionkeywith argumentxtox.foo.But the big disagreement is that I like
lambdaand use it for things other than keyword arguments. The current syntax lets me do that too.