Ned Batchelder writes:
"lambda" is unnecessarily obscure.
And it should be. It's really only useful as an argument. There's no advantage to foo = (x) -> 1 vs. def foo(x): return 1 except a couple of characters. So what currently looks like some_list.sort(key=lambda e: e[3].priority) would then be some_list.sort(key=(e)->e[3].priority) which is shorter but not particularly more readable (and already has a familiar meaning in C-like languages). It seems to me that two changes to def might be considered: 1. In a one-line def of the form "def foo([arglist]): return EXPR", "return" may be omitted, and the function returns the value of EXPR (rather than None as currently). (As a multiline def, EXPR would be presumed to be evaluated for side effects, and 2. As an actual argument, a one-line def is interpreted not as a positional argument, but as a keyword argument, so that in some_list.sort(def key(e): e[3].priority) the name "key" is not optional, and must match a keyword argument. I suggest 1 for "ordinary" defs as well for consistency, but evidently we could also restrict that usage to "def as keyword argument", and maintain backwards compatibility. 2 could even be independent of 1: some_list.sort(def key(e): return e[3].priority) but that seems excessively verbose. Another possible use case would be in a for loop: for fun in [def fun(): return 1, def fun(): return 2, def fun(): return 3]: do_something_with(fun) where similarly the loop variable needs to match the def.
Beginner: "why is it called lambda?"
Teacher: "Don't worry about it, just use it to define a function"
It me. But it would go like this: Teacher [face lights up at the chance to talk math history]: "You see, ..." Students [in harmony]: "NOOOOOOOOooooooo.......... :-(" [collective sigh] Regards, Steve