Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Variable Scope
00:00 The existence of multiple distinct namespaces means multiple instances of a name can exist simultaneously while a Python program runs. As long as each instance is in a different namespace, they are all maintained separately and won’t interfere with one another.
00:20
But that raises a question. Suppose you refer to the name x in your code and x exists in several namespaces. How does the Python interpreter know what you mean?
00:33 The answer lies in the concept of scope. The scope of a name is the region in a program in which that name has meaning. The interpreter determines this at runtime based on where the name definition occurs and where in the code the name is referenced.
00:53 In the next lesson, you will get a breakdown of how the Python interpreter looks through the layers of scope.
Become a Member to join the conversation.