Ron Adam <[EMAIL PROTECTED]> writes:

> By not limiting parent to just the parent scope you create exceptions.  The 
> rule 
> becomes:
>
>      The keyword (*)nonlocal designates a name will be written to in the
>      closest enclosing "parent" scope *except* when a pre-existing matching 
> name
>      exists in a scope further up.
>
> To me that is more confusing than always referring to the closest enclosing 
> scope without exception.

The rule should be:

The keyword 'nonlocal' causes the lookup to be performed as if there
were no assignments to that variable in the scope containing the
'nonlocal' declaration.

No exceptions are needed, and no limitation to the immediately
surrounding scope is needed. Read accesses already have fine scoping
rules, as long as there is something to determine the scope. The only
problem with current rules is that assignment is coupled with creating
a new variable, and 'nonlocal' just allows to decouple that.

-- 
   __("<         Marcin Kowalczyk
   \__/       [EMAIL PROTECTED]
    ^^     http://qrnik.knm.org.pl/~qrczak/
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to