What is Scope Resolution in Python?

:thinking: :thinking: :thinking:

I’m not sure what you mean by “scope resolution”, but I think it means
the rules that the interpreter uses to decide which scope a variable
belongs in.

The rules are a little complicated, but for a high-level overview google
for “Python LEGB scope”. For some of the history behind it, look for the
“nested scope” PEP:

https://www.python.org/dev/peps/pep-0227/

Some complications that are captured by the LEGB acronym include classes
and comprehensions.

1 Like