Python Lexical Scoping
Mon Jan 30 2023 18:04:15 GMT+0000 (UTC)
Saved by @abell_ds
A nested Python function can refer to variables defined in enclosing functions, but cannot assign to them. Variable bindings are resolved using lexical scoping, that is, based on the static program text. Any assignment to a name in a block will cause Python to treat all references to that name as a local variable, even if the use precedes the assignment. If a global declaration occurs, the name is treated as a global variable.
https://google.github.io/styleguide/pyguide.html
Comments