Barry wrote:

> The ways scoping works in python is very hard to change as you are asking
for i think was a major reason to reject.

Perhaps it isn't all that difficult;

For instance, a "local:" declaration could be treated as if it were "def
function()" with an immediately succeeding call as far as the interpreter
is concerned. That buys the scoping for (nearly) free.

We write...

local:
    for MyVal in range(0,10)
        pass

...interpreter codes that, out of sight, as:

def ghost_func_0000001():
    for MyVal in range(0,10)
        pass
ghost_func_0000001()

Might take a bit of fiddling to make sure return and yield were appropriate
[requiring an actual enclosing def function():], but other than that, it's
basically the same idea -- provides scoping, making it easier for us to
code, debug, and document, while significantly decreasing the likelihood of
variable collisions.

--Ben
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MOBLBH6JTOYE4SDK27RE6CGRSD6TJLOJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to