[Python-ideas] Lambda again: Anonymous function definition

Tal Einat taleinat at gmail.com
Thu Apr 3 15:20:46 CEST 2008

Talin 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...
>From my experience anonymous functions are very useful when writing
event-based code, such as client-side event handlers for web browsers
with JavaScript, Expect event handlers in Tcl/Perl, and GUI event
handlers in any language. I think having a simple, readable way to
define anonymous functions in Python would allow writing more concise
and readable Python code for such applications, thus making Python an
even better Jack-of-all-trades.

However, even if it were easy to implement with clear, simple syntax,
I'm not sure this would be a good idea; I'd leave this to more
experienced language developers.

- Tal

More information about the Python-ideas mailing list