[Python-ideas] Where-statement (Proposal for function expressions)

Paul Moore p.f.moore at gmail.com
Thu Jul 16 17:06:13 CEST 2009


2009/7/16 Chris Perkins <chrisperkins99 at gmail.com>:
> As for the precise specification, I see only a few issues.
>
> As a first approximation, assume that this code:
>
> [LHS OP] EXPR where:
>    BODY
>
> is expanded into the equivalent of this:
>
> def TEMP():
>    BODY
>    return EXPR
> [LHS OP] TEMP()

So where constructs are only allowed for code of the form [LHS OP] EXPR?

What does that correspond to in the grammar? (If it doesn't correspond
to something at the moment, you'll need to extend the grammar to
define a "thing that can have a where clause" production...)

You've also disallowed

x[i] = 12 where:
    i = some_complicated_expression()

Was that deliberate? If so, could you explain why now, so that it's on
record for the legions of people who will ask after it's implemented?
:-)

Paul.



More information about the Python-ideas mailing list