[Python-Dev] statically nested scopes

M.-A. Lemburg mal@lemburg.com
Fri, 03 Nov 2000 11:02:13 +0100


Jeremy Hylton wrote:
> 
> Looks like we need to rehash this thread at least enough to determine
> who is responsible for causing us to rehash it.
> 
> MAL said it would break code.  I asked how.  Skip and Tim obliged with
> examples.  I said their examples exhibited bad style; neither of them
> claimed they were good style.
> 
> In the end, I observed that while it could break code in theory, I
> doubted it really would break much code.  Furthermore, I believe that
> the code it will break is already obscure so we needn't worry about
> it.

That's just what I was trying to say all along: statically
nested scopes don't buy you anything except maybe for lambdas
and nested functions (which is bad style programming, IMHO too).

The only true argument for changing scoping I see is that
of gained purity in language design... without much practical
use.  

Other issues that need sorting out:

x = 2
class C:
  x = 1
  C = 'some string'
  def a(self):
     print x
  def b(self):
     global x
     x = 3

class D(C):
  C = 'some string'
  def a(self):
     C.a(self)
     print C

o = C()
o.a()
o.b()
o.a()

o = D()
o.a()

What would the output look like under your proposal ?

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/