اسکوپ‌ها در پایتون و ترتیب اولویت آن‌ها

اولویت و ترتیب اسکوپ‌ها: Local, Enclosing, Global, Built-in

x = 'global x'
def outer():
    x = 'enclosing x'
    
    def inner():
        x = 'local x'
        print(x)

    inner()
    print(x)

outer()
print(x)

def max(a):
    return sum(a)

# global max
max([1, 2, 3])