nested scopes

clee at thalamus.wustl.edu clee at thalamus.wustl.edu
Sat Feb 3 17:35:31 EST 2001


In article <mailman.981230290.31442.python-list at python.org>,
  "Tim Peters" <tim.one at home.com> wrote:

> Python's "2-level" scheme was a deliberate counterpoint to the abuses of
> deep lexical nesting in Pascal programs of the time (according to Guido),
> and it's something I've grown to like a lot.  But newbies eternally
stumble
> over that functions nest textually but not lexically in Python, and this
> will make life simpler for them.

Out of curiosity, were explicit declarations for whether scopes nest
ever considered?  Something like:

def f():
    A = 1
    closure: # all functions declared in this block can access f's
             # variables
        def g():
            A = 2

Alternative names for closure might be be "bindlocals" or something.  I
guess this doesn't minimize a beginner's surprise, but it would prevent
code breakage.

  -chris


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list