[Python-Dev] Use an empty def as a lambda

Westley Martínez anikom15 at gmail.com
Sat Sep 21 03:27:16 CEST 2013

'def' is no more ambiguous than 'lambda', and is in fact more ambiguous,
for 'def' doesn't lend itself to anything other than the word define,
whilst 'lambda' can only mean lambda function.  Calling def explicit is
silly.  It only makes sense because def arbitrarily means a function in
Python (I'm proposing def become func or proc in Python 4000).

To call lambda too 'computer sciencey' is equally ridiculous, for pro-
gramming is a key spawn of computer science.  A programmer needs to have
some knowledge of computer science to program, just like a physicist
needs knowledge of calculus to understand mechanics.

> -----Original Message-----
> From: Python-Dev [mailto:python-dev-bounces+anikom15=gmail.com at python.org] On
> Behalf Of Ben Gift
> Sent: Thursday, September 19, 2013 1:54 PM
> To: python-dev at python.org
> Subject: [Python-Dev] Use an empty def as a lambda
> I think the lambda keyword is difficult to understand for many people. It
> would be more pythonic to use an empty def call instead.
> For instance this:
>     words.sort(key = lambda x: x[2])
> could look like this:
>     words.sort(key = def (x): x[2])
> It's obvious and explicit that we're creating an unnamed, anonymous function
> this way.

More information about the Python-Dev mailing list