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

Paul Moore p.f.moore at gmail.com
Thu Jul 16 23:25:32 CEST 2009


2009/7/16 Daniel Stutzbach <daniel at stutzbachenterprises.com>:
> On Thu, Jul 16, 2009 at 1:51 PM, Paul Moore <p.f.moore at gmail.com> wrote:
>>
>> Thinking about it, the issue is that you're making where the *only*
>> example in Python (that i can think of) of a non-defining construct
>> which creates a new scope.
>
> I think that's why the "where" clause is being proposed: because there's no
> construct to create a new scope without defining a new class or function.

That's a very interesting perspective. Maybe then it would make more
sense to simply bite the bullet and define a scope-creating statement
-

scope:
  i = a_complicated_expression()
  x[i] = 15

Without a way of having some values "escape" the scope, this may be a
bit limited, though. And it's almost certainly not going to appeal to
the people who want to see the expression first, and the subordinate
names defined afterwards. But that's a different underlying concept -
a new construct to execute code in something other than top-to-bottom
order (and one I have less interest in, personally).

Paul.



More information about the Python-ideas mailing list