[Python-3000] lambda
Nick Coghlan
ncoghlan at gmail.com
Wed Mar 26 15:46:02 CET 2008
Olivier Verdier wrote:
> There is a dislike of the lambda construction that I just don't
> understand. Lambda is very practical in all sorts of situations, like:
> lambda x,y: x+y. I just find the name plain silly, that's all. Perhaps
> you think that all python programmers or beginners have a LISP
> background, but that's just not the case. For me and my mathematician
> colleagues, lambda is just a letter of the greek language.
I think if I come across a keyword I didn't know in a language I was
learning, I'd look it up to find out what it means. Lambda calculus is a
well established field of mathematics, so it's a perfectly valid name
for the construct.
> Python has a very clear syntax and is increasingly used instead of
> pseudo-code in text books. Some of you seem not to be aware of the
> clarity of the language. List comprehensions, and strings are all very
> clear for beginners (the name "string" is not needed to understand: x =
> "message"). Reading a python code is a pleasure, *even for one not
> versed in python*. This is a crucial advantage of the language. "lambda"
> is not as clear as the rest of the language. I hope you understand my point.
So don't use it. Use a named function instead. Then it will be even more
of a pleasure to read, because the name you choose will tell the reader
what the function is for. You can even attach a docstring to make it
really obvious.
> I thought that the upcoming of python 3000 would be a good opportunity
> to change this name but since few or no python beginners or newcommers
> are reading this mailing list I don't think that I will get a lot of
> support here. :-)
For a long time, lambda functionality wasn't going to exist in Py3k at
all. It certainly isn't going to get enough care and attention to
warrant Guido expending the mental energy needed to arbitrarily choose a
new name, and anyone else going through the code and docs changing it.
Python beginners and newcomers should be steered completely clear of
anonymous functions anyway. Give you functions a name, or use one of the
builtin callables from the operator module.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list