
Nice idea, BUT... Not sure how a parser addition that supports it would go. Imagine this: if you did a one-line function: def test(x): print(x) Python could interpret it two ways: `def` `name` `lparen` `name` `rparen` `colon`... OR, it could see it as a lambda-like thingamajig and throw a syntax error. And, if someone accidentally wrote: def (x): print(x) Python should throw a syntax error. But it won't. And it'll take the person a tad bit to realize he forgot the function name. Whoops. And, it just would be odd in general. On Thu, Sep 19, 2013 at 3:54 PM, Ben Gift <benhgift@gmail.com> wrote:
I think the lambda keyword is difficult to understand for many people. It would be more pythonic to use an empty def call instead.
For instance this:
words.sort(key = lambda x: x[2])
could look like this:
words.sort(key = def (x): x[2])
It's obvious and explicit that we're creating an unnamed, anonymous function this way.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com
-- Ryan