Within a function in Python, you can read from global variables and read from or write to local variables. Within each function, each variable name is either local or global (but not both).
All assignments assign to local variables in Python, unless you use an escape hatch to assign to global variables. But assigning to global variables from within a function is usually discouraged.
Remember the "two types of change" in Python? Scope is all about one of those two types of change: assignment. Python's scope rules are unrelated to mutation.
"Global" variables in Python aren't available everywhere. The global variables in one module are different from those in another module. Python's built-ins are the only truly universal variables.
Python resolves variable names through its four scope levels: local, enclosing, global, and built-in.
Continue exploring
Learn something new about Python every week
My name is Trey Hunner. I publish new Python articles and screencasts every week through Python Morsels. If you want to learn something new about Python every week, join Python Morsels!