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

Terry Reedy tjreedy at udel.edu
Tue Jul 20 21:49:49 CEST 2010


On 7/20/2010 1:29 AM, Stephen J. Turnbull wrote:
> Sergio Davis writes:
>
>   >  I'm considering the following extension to Python's grammar: adding the
>   >  'where' keyword, which would work as follows:
>   >
>   >  where_expr : expr 'where' NAME '=' expr
>
> We just had a long thread about this.
>
> http://mail.python.org/pipermail/python-ideas/2010-June/007476.html
>
> The sentiment was about -0 to -0.5 on the idea in general,

I did not comment then because I thought the idea of cluttering python 
with augmented local namespace blocks, with no functional gain, was 
rejected and dead, and hence unnecessary of comment.
-10
For me, the idea would come close to destroying (what remains of) the 
simplicity that makes Python relatively easy to learn. It seems to be 
associated with the (to me, cracked) idea that names are pollution.

I agree with Jack Diederich:
 >I think the "trick" to making it readable
 > is putting the assignment first.

 > par_pos = decl.find('(')
 > vtype = decl[par_pos+1:FindMatching(par_pos, decl)].strip()

 > versus:

 > vtype = decl[par_pos+1:FindMatching(par_pos, decl)].strip() where
 > par_pos=decl.find('(')

The real horror would come with multiple assignments with multiple and 
nested where or whatever clauses.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list