For better or worse, except for string literals which can be anything as long as you set a coding comment, python is pure ascii which simplifies everything. Lambda is not in the first 128 characters of Unicode, so it is highly unlikely to be accepted.
* ‘Lambda’ is exactly as discouraging to type as it needs to be. A more likely to be accepted alternate keyword is ‘whyareyounotusingdef’
* Python doesn’t attempt to look like mathematical formula
* ‘Lambda’ spelling is intuitive to most people who program
* TIMTOWTDI isn’t a religious edict. Python is more pragmatic than that.
* It’s hard to type in ALL editors unless your locale is set to (ancient?) Greek.
* … What are you doing to have an identifier outside of ‘[A-Za-z_][A-Za-z0-9_]+’?
From: Python-ideas [mailto:python-ideas-bounces+tritium-list=sdamon.com@python.org] On Behalf Of Stephan Houben
Sent: Tuesday, July 12, 2016 8:38 AM
To: python-ideas@python.org
Subject: [Python-ideas] allow `lambda' to be spelled λ
Hi list,
Here is my speculative language idea for Python:
Allow the following alternative spelling of the keyword `lambda':
λ
(That is "Unicode Character 'GREEK SMALL LETTER LAMDA' (U+03BB).")
Background:
I have been using the Vim "conceal" functionality with a rule which visually
replaces lambda with λ when editing Python files. I find this a great improvement in
readability since λ is visually less distracting while still quite distinctive.
(The fact that λ is syntax-colored as a keyword also helps with this.)
However, at the moment the nice syntax is lost when looking at the file through another editor or viewer.
Therefore I would really like this to be an official part of the Python syntax.
I know people have been clamoring for shorter lambda-syntax in the past, I think this is
a nice minimal extension.
Example code:
lst.sort(key=lambda x: x.lookup_first_name())
lst.sort(key=λ x: x.lookup_first_name())
# Church numerals
zero = λ f: λ x: x
one = λ f: λ x: f(x)
two = λ f: λ x: f(f(x))
(Yes, Python is my favorite Scheme dialect. Why did you ask?)
Note that a number of other languages already allow this. (Racket, Haskell).
You can judge the aesthetics of this on your own code with the following sed command.
sed 's/\