[Python-ideas] 'where' statement in Python?

Nick Coghlan ncoghlan at gmail.com
Wed Jul 21 23:58:15 CEST 2010

On Thu, Jul 22, 2010 at 1:51 AM, Bruce Leban <bruce at leapyear.org> wrote:
> I'm unconvinced of the value at this point but notwithstanding that let me
> toss in an alternative syntax:
>     given:
>         suite
>     do:
>         suite
> This executes the two suites in order with any variable bindings created by
> the first suite being local to the scope of the two suites. I think this is
> more readable than the trailing clause and is more flexible (you can put
> multiple statements in the second suite) and avoids the issue with anyone
> wanting the where clause added to arbitrary expressions.
> FWIW, in math it's more common to list givens at the top.

However, writing it that way has even less to offer over ordinary
local variables than the postfix given clause.

I updated the draft PEP again, pointing out that if a decision had to
be made today, the PEP would almost certainly be rejected due to a
lack of compelling use cases. The bar for adding a new syntactic
construct is pretty high and PEP 3150 currently isn't even close to
reaching it (see PEP 343 for the kind of use cases that got the with
statement over that bar).


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list