[Python-ideas] Multi Statement Lambdas

Anders Hovmöller boxed at killingar.net
Sun Oct 21 12:33:39 EDT 2018

> Wheres a lambda expression can be passed anonymously to any other function as an argument.
> map(lambda x: x**2, array)
> vs 
> def powers2(x)
>    x**2
> map(powers2, array)
> Coming up with a name here is not needed, as the operation is expressive enough. 

Sure, but there is a well known convention for such non-names already: meta syntactical variables. In this case the name could be "foo" and all readers will interpret this as "no name". 

I admit to have wanted lambdas that are just as powerful as normal functions, but often when I want it the code is nicer when a normal function is used. 

/ Anders
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181021/7e2bdca3/attachment.html>

More information about the Python-ideas mailing list