only the most local and global namespaces can be modified : Global : Function PYTHON TUTORIALS


PYTHON TUTORIALS » Function » Global »

 

only the most local and global namespaces can be modified


x = 1
def fun(a):
    b=3
    x=4
    def sub(c):
        d=b
        global x
        x = 7
        print ("Nested Functionn")
        print locals()

    sub(5)
    print ("nFunctionn")
    print locals()
    print locals()["x"]
    print globals()["x"]

print ("nGlobalsn")
print globals()

fun(2)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Function
» Global