File: LP6E/Chapter17/scopes101.py

# Global scope
X = 99                # X and func assigned in module: global

def func(Y):          # Y and Z assigned in function: locals
    # Local scope
    Z = X + Y         # X is a global when referenced here
    return Z

func(1)               # func in module: result=100



[Home page] Books Code Blog Python Author Train Find ©M.Lutz