[Python-ideas] 'where' statement in Python?
Raymond Hettinger
raymond.hettinger at gmail.com
Sat Jul 24 01:38:33 CEST 2010
On Jul 21, 2010, at 2:58 PM, Nick Coghlan wrote:
> 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.
Sounds like a LISP letrec.
>
> 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).
>
I concur.
Raymond
More information about the Python-ideas
mailing list