[Python-ideas] 'where' statement in Python?
Chris Rebert
pyideas at rebertia.com
Thu Jul 22 05:30:17 CEST 2010
On Wed, Jul 21, 2010 at 7:12 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 7/21/2010 7:20 AM, Nick Coghlan wrote:
>
>> yield and return (at the level of the given clause itself) will need
>> to be disallowed explicitly by the compiler
>
> Why introduce an inconsistency?
>
> If
>
> a = e1
> b = f(a)
>
> can be flipped to
>
> b = f(a) given:
> a = e1
>
> I would expect
>
> a = e1
> return f(a)
>
> to be flippable to
>
> return f(a) given
> a = e1
I believe Nick meant returns/yields *within* the `given` suite (he
just phrased it awkwardly), e.g.
a = b given:
b = 42
return c # WTF
The PEP's Syntax Change section explicitly changes the grammar to
allow the sort of `given`s you're talking about.
Cheers,
Chris
More information about the Python-ideas
mailing list