Python Notes and Examples
← prev | next →     Top-level ToC     /scoping.html     (printable version)

Python has file scope and function scope.

Because Python doesn’t have variable declarations, it’s not always obvious whether you’re assigning to an existing variable, or creating a new one.

See also the global and nonlocal keywords.