[Python-ideas] A simple proposal concerning lambda

Steven D'Aprano steve at pearwood.info
Wed Aug 22 12:57:23 EDT 2018


On Wed, Aug 22, 2018 at 04:58:17PM +0100, Jonathan Fine wrote:
> I wrote:
> 
> > Here is my simple proposal. Enhance Python to allow
> >
> > >>> hn = def a, b=2, c=3: a ** b / c
> 
> I'd like to add a clarification. Here are two proposals.
> 
> ONE.  Wherever you could have used 'lambda', you now have a choice.
> You can still use 'lambda', or you can use 'def' instead. The
> semantics are unchanged.
> 
> TWO.  Wherever you could have used 'lambda', you must now use 'def'
> instead. The semantics are unchanged.
> 
> I'm proposing ONE, not TWO. All existing Python code will continue to
> run exactly as before. No Python code will have to be changed. And no
> new programming capabilities would be added.
> 
> So why do it? In a nutshell, to remove an obstacle. 

And add a new obstacle:

"What's the difference between function expressions created with def and 
function expressions created with lambda?"

"Nothing."

"So why do I have to learn TWO sets of syntax for exactly the same 
thing?"

"Because its easier than learning one!"



> To make DEFerred expressions easier to understand.

They're not "deferred expressions", they're functions.

It is true that function bodies contain deferred expressions (or 
statements), but the whole is not the part.



-- 
Steve


More information about the Python-ideas mailing list