[Python-ideas] 'where' statement in Python?
stefan_ml at behnel.de
Wed Jul 21 13:16:37 CEST 2010
Terry Reedy, 20.07.2010 21:49:
> 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.
> 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.
Actually, it's about *giving* names to subexpressions, that's quite the
> 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.
I agree that the placement *behind* the expression itself *can* be
suboptimal, but then, we also have conditional expressions, where it's good
to know when to use them and when they get too long to be readable. The
same applies here.
However, I take your point that this is nothing that really makes anything
simpler or that potentially opens new use cases (like the 'with' statement
did, for example). It's a plain convenience syntax and as such not really
worth defending over potential draw-backs.
More information about the Python-ideas