[Python-ideas] Query about proposed Multi-line Anonymous Function syntaxes

random832 at fastmail.us random832 at fastmail.us
Fri Oct 10 21:25:25 CEST 2014


On Fri, Oct 10, 2014, at 14:42, Guido van Rossum wrote:
> Well, it's worse -- it's hard to propose a syntax that actually works
> without huge changes to the way Python's parser treats indentation:
> inside
> parentheses, indentation is currently *not* significant.

What about forgetting about indentation entirely, and just using
semicolons. You could use an extra semicolon to "break out" of the scope
created by e.g. an if statement.

lambda a: (if a: b; c;; else d; e;)

equivalent to def f(a):
    if a:
        b
        return c
    else:
        d
        return e

Basically, is the real reason people ask for multi-line lambdas because
they want multiple lines, or just because they want multiple statements?
And conversely, if you don't like the implications of allowing an
unlimited number of statements of any kind on one line / within an
expression, do you really want to give them multi-line lambdas, even if
the syntax issue magically resolved itself?


More information about the Python-ideas mailing list