Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

And so it goes, around again. Charles Miller on Java, pointing out that if you don’t have closures and first-class functions you end up having to add band-aid solutions and special case syntactic sugar. Python’s lack of multi-line lambdas leads to a similar (though less pronounced) effect.

Tagged , , ,

3 comments

  1. >>> lambda x: ('this is a',
    ... 2, 'line, multi-line lambda in python.')
    <function <lambda> at 0x77830>

    Rene Dudfield - 4th September 2009 09:17 - #

  2. (Simon, your "Sign in with OpenID" link for comments seems broken; when I entered Google's OpenID endpoint URL, your web site gave me a 404 Not Found error.)

    I think that Python's "small lambda" requirement is a strength. When you create a lambda, you are creating a function and asserting, "This function is so simple that it needs neither a name, nor a docstring, nor a test suite." I like the fact that programmers can only do this with one-liners. When a helper function expands to two or more lines, I really like the fact that it gets a name and can therefore be seen, tried out, and, if I want to, tested. The ability to hide multi-line callables would make Python more obscure, like Ruby.

    Brandon Rhodes - 4th September 2009 13:41 - #

  3. Many people in the Python community claim that not having full anonymous function support is a feature.

    Having used languages where they are supported - like the anonymous delegates in C# - I can tell you that they *are* useful and can *increase* readability. They move the code to the point they are used.

    Having said that I can't see an easy way of introducing a Pythonic syntax for them - but their lack is definitely a limitation in Python.

    Michael Foord - 4th September 2009 13:49 - #

Comments are closed.
A django site