[Python-ideas] Thoughts on lambda expressions
Mike Miller
python-ideas at mgmiller.net
Wed Mar 2 19:00:46 EST 2016
On 2016-03-02 15:03, Paul Moore wrote:
> PS For the record, I dislike the lambda syntax intensely - the odd
> keyword, the fact that "lambda" is sometimes almost as long as than
> the expression I'm using, the use of the mid-line colon which is hard
> to spot, ... So in principle I'm inclined to support "improvement"
Hmm, can't think of a way to get rid of the colon without it looking like a
generator, but perhaps we could tackle the other issues by letting "def" stand
in for "lambda":
lambda x: x.y
def x: x.y
It's shorter, not an esoteric word, and is analogous to a named function
definition, reminiscent of javascript. The lack of name/parens separates it
from the standard form. Doable, but of course its pretty late in the game to be
changing lambda, perhaps in Python 4?
-Mike
More information about the Python-ideas
mailing list