3 ms·
Python has nested functions which does allow access to the nest...er function's variables. The rest does conform to expectations, you get to use parameters, loc
by rzzzt 2y ago
Python has nested functions which does allow access to the nest...er function's variables. The rest does conform to expectations, you get to use parameters, locally declared variables and globals.
- antonvs 2y agoI'm not too familiar with Python, but isn't that just lexical scope, the same as most languages that support nested functions? Starting with the lambda calculus and all the languages it influenced, including even JavaScript.
- meowface 2y agoCorrect. It behaves like JavaScript and many other languages. You can't modify such variables in the outer scope from the inner scope unless you explicitly use the "nonlocal" declaration.