Securing a future for anonymous functions in Python
tim.peters at gmail.com
Tue Jan 11 03:15:50 CET 2005
>> BTW - I am *quite* happy with the proposal for "where:" syntax - I
>> think it handles the problems I have with lambda quite handily.
> Whereas I find it to be an excrescence, proving (I suppose) that one
> man's meat is another person's poison, or something.
I've been waiting for someone to mention this, but looks like nobody
will, so I'm elected. Modern functional languages generally have two
forms of local-name definition, following common mathematical
conventions. "where" was discussed here. The other is "let/in", and
seems a more natural fit to Python's spelling of block structure:
There's no restriction to expressions here. I suppose that, like the
body of a class, the `let` suite is executed starting with a
conceptually empty local namespace, and whatever the suite binds to a
local name becomes a temporary binding in the `in` suite (like
whatever a class body binds to local names becomes the initial value
of the class __dict__). So, e.g.,
i = i1 = 3
i1 = i+1
from math import sqrt
print i1, sqrt(i1)
and then blow up with a NameError.
LIke it or not, it doesn't seem as strained as trying to pile more
gimmicks on Python expressions.
More information about the Python-list