[Python-ideas] Multi Statement Lambdas
Chris Angelico
rosuav at gmail.com
Sun Oct 21 19:25:19 EDT 2018
On Mon, Oct 22, 2018 at 10:16 AM Terry Reedy <tjreedy at udel.edu> wrote:
>
> On 10/21/2018 12:28 PM, Andreas Winschu wrote
>
> > A def function has to be named.
>
> In general, this is a good thing. It often improves tracebacks.
> Perhaps more importantly, name facilitate testing and mocking.
>
> > Wheres a lambda expression can be passed anonymously to any other
> > function as an argument.
>
> Except for relatively trivial expressions, this is a bad thing. All
> functions created from lambda expressions get the same pseudo-name
> '<lambda>'. This can make tracebacks worse. Perhaps more importantly,
> proper testing may become harder.
The same considerations bite comprehensions, too, but we don't
discourage their use. So I don't think this should be a killer - not
on its own, anyhow.
I do not currently support any proposed syntax for multi-statement
lambda functions, mainly because they've all been ugly. But maybe
there'll be one, somewhere, some day, that makes sense.
ChrisA
More information about the Python-ideas
mailing list