[Python-ideas] Lambda again: Anonymous function definition

Eli Courtwright eli at courtwright.org
Thu Apr 3 15:57:31 CEST 2008


On Wed, Apr 2, 2008 at 9:49 PM, Talin <talin at acm.org> wrote:

> Matt Chisholm wrote:
> > +1 to handling anonymous functions/lambdas the way JavaScript does.
> > It's the only thing I like better about JavaScript than Python.
>
> Unfortunately, there's no way in Python to have a statement inside of an
> expression (because statements are delimited by line ends and
> indentation). Many people have attempted this, none have succeeded.
> Don't go there, you'll just be opening up old wounds...


Well what's being proposed is for

def f(x, y): return x*x + y*y

to be a statement, but for

def(x,y): x*x + y*y

to be an expression.  In other words, anonymous def will behave exactly like
lambda does now.  This seems doable, though I don't know Python's parsing
code well enough to understand how difficult it would be to implement.

Of course, we all understand that lambda won't change anytime soon; this is
really more of a hypothetical "what if we did this in 10 years if there's
ever a Python 4000" discussion.

- Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20080403/c6b89d97/attachment.html>


More information about the Python-ideas mailing list