> 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.
Exactly. There is no reason to place an artificial limitation on this feature. This is also why I advocate the spelling "use", because ISTM "use x" pretty much means exactly what it says. The main argument against the spelling "use" that I've seen is that it's too generic, i.e, one could "use" anything. This argument doesn't sway me because whatever we call the keyword, I think the programmer will have to look it up in the docs the first time they encounter it. Then they'll say "aha, I get it" and move on -- a minor one-time bump on the learning curve. Once you know what the keyword means, I think "use" is the spelling that makes the most sense, and it's easy to type, too. Mike _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
