News

006_Variable_Scopes In Python, a scope refers to the region of a program where a particular variable is defined and can be accessed. In general, Python has two main types of scopes, Global and Local.
Python scope resolution is based on what is known as the LEGB rule, which is shorthand for L ocal, E nclosing, G lobal, B uilt-in. Even though it looks pretty simple, it’s was very confusing for ...
LEGB: local, enclosing, global, built-in So how exactly does Python go about finding identifiers, including free variables in functions? Python uses the “LEGB” rule: local, enclosing, global and built ...