Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
Lecture 70: Meaning of Scope Rule of a function in Python
22 Views • May 21, 2025
Description
Local (L):
This scope encompasses names defined within the current function. If a variable name is found in the local scope, Python uses that value.
Enclosing function locals (E):
If the name is not found locally, Python searches the scopes of any enclosing functions (in nested functions).
Global (G):
If the name is not found in any enclosing scopes, Python looks in the global scope, which includes names defined at the top level of the module.
Built-in (B):
Finally, if the name is not found in the global scope, Python checks the built-in scope, which contains pre-defined functions and constants.
If a variable is assigned a value within a function, it is generally considered local to that function, unless explicitly declared as global using the global keyword. Variables defined outside of any function are considered global and can be accessed from within functions, although their values can only be modified within a function if declared global.
More from User
Episode 1 – The Curious Boy from Ulm (1879-1895)
Nafees AI Lab
Top Fully Funded Scholarships in Germany 2025 🇩🇪 | Apply Now!
Nafees AI Lab
The Boy and the Dragon – “A Friend in the Sky”
Nafees AI Lab
Why Do Rainbows Appear? 🌈 | Physics in Everyday Life
Nafees AI Lab
Albert Einstein: The Genius Who Changed Time
Nafees AI Lab
Stephen Hawking’s Life in 60 Seconds: From Wheelchair to the Universe
Nafees AI Lab
Related Videos
Lecture 69: What is the meaning *Scope* of a function in Python Programming
Nafees AI Lab
Lecture 71: Scope Rule-II in Python
Nafees AI Lab
Lecture 74: Python has Special Function Map
Nafees AI Lab
Lecture 60: Python has some functions
Nafees AI Lab
Lecture 61: Why of functions are in Python Language
Nafees AI Lab
Lecture 67: What are *args and **kwargs used for in Python functions?
Nafees AI Lab