[Python-ideas] Thoughts on lambda expressions

Chris Angelico rosuav at gmail.com
Wed Mar 2 19:27:30 EST 2016


On Thu, Mar 3, 2016 at 11:01 AM, Abe Dillon <abedillon at gmail.com> wrote:
> Typing 'lambda' is not at all my concern, in fact `(x+1 from x)` takes the
> same number of keystrokes as `lambda x:x+1`. My complaint is in readability
> which is supposed to be Python's strong suit. To most people, 'lambda' is
> pretty much a nonsense word. It might as well be 'quaple'. Would you be ok
> with writing:
>
> sorted(words, key=quaple word: edit_distance(word, "hello"))

There's a difference between nonsense and jargon, though. Words used
in programming languages are most often borrowed from a parent
language (in Python's case, that's usually either English or algebra),
but they don't always retain their exact meanings. Simple words like
"if" and "while" are very close to their originals, but "def" (aka
"define") has a very broad meaning in English, and doesn't necessarily
have to mean "create a function" as it does in Python. No matter what
your background is, you'll need to learn at least some of the syntax.
Most of us probably learned what + means in grade school; but in
algebra, "ab" means "a multiplied by b", whereas Python (like most
other programming languages) allows variables to have multiple letters
in their names, and spells multiplication with an asterisk. If you
have to learn that "quaple" or "lambda" means "anonymous function", is
that really worse than learning that "<expression> from <name list>"
means "anonymous function"?

ChrisA


More information about the Python-ideas mailing list