local variable hides global : Local Variables « Language Basics « Python






local variable hides global

local variable hides global

X = 88          # global X

def func():
    X = 99      # local X: hides global

func()
print X         # prints 88: unchanged

           
       








Related examples in the same category

1.locals() Is Read-Only: globals() Is Notlocals() Is Read-Only: globals() Is Not