Python : Scope resolution in python programming.

 


Scope Resolution mentions the scope of a variable ,function or class in python. Scope resolution decides whether a variable has to be of a local scope or global scope.

Example1: The example shows how to impact a global variable inside a local function scope so that changes made inside the local variable remains permanently through the program.

Code:
var_global = 10
def test():
    # Impacting a global variable
    global var_global   
    var_global = 20
test()
print(var_global)
    

Comments