Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

To clarify further, unlike (say) Lua, Python doesn't allow variables to change 
scope part-way through a function. (At least not without hacking the 
byte-code.) In any function, a name refers to precisely one of (1) a local, (2) 
a nonlocal, and (3) a global, so you cannot have something like this:

a = 1
def func():
    print(a)  # refers to global a
    a = a + 1  # make a new local 'a'

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37568>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to