[Python-Dev] Lexical scoping in Python 3k

Josiah Carlson jcarlson at uci.edu
Mon Jul 3 08:08:33 CEST 2006


"Guido van Rossum" <guido at python.org> wrote:
> 
> On 7/3/06, Josiah Carlson <jcarlson at uci.edu> wrote:
> >
> > Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > > Josiah Carlson wrote:
> > > > If the only code that benefits from such changes are "very *simple*",
> > > > then I think that says something about its necessity.
> > >
> > > The point is that they're only "very simple" if you
> > > can write them using access to an outer scope. Without
> > > that ability, they become less simple, less efficient,
> > > more convoluted, harder to follow, etc.
> >
> > As is known and has been stated, assigning to a parent scope can be
> > emulated in various ways, either through an explicit namespace object, or
> > through a namespace list.
> 
> And the fact that this desire and need remains, even amongst people
> who should know better, suggests that it may be worth supporting it
> more directly, as the current work-arounds ain't pretty.


Perhaps not pretty, but not wholly ugly either.  Or expressed another
way, it's a wart, but the wart isn't 1" across on a forehead, it's
fairly small and tucked away on an elbow.

I had hoped that there would be a response to my second (and I believe
more applicable statement); "if the feature is really only useful for
generally trivial cases *without* the feature, then making them even
more trivial, I think, is a bit of over optimization."

As for a solution, I find the "global means 'not local'" proposition is
the least undesireable of the possibilities.  It suffers from a change
in semantics and potential name masking issues, but I don't believe
these are any more serious than normal global masking for the former,
and the latter is solvable with a __future__ (at least for 2.6). I'm a
solid -0 on this particular proposition, which is far better than the -1
I am on all of the other recent lexical scoping propositions.

 - Josiah



More information about the Python-Dev mailing list