Quick actions

cmd+k|ctrl+k

Navigation

Languages

nonlocal example

Snippet info

Language

Python

Visibility

public

Author

glot.rotunda236

Created

2026-01-17T14:35:13.151443Z

Updated

2026-01-17T14:36:15.172821Z

# This is in regards to Scope

def outer():
    x = 'local'
    def inner():
        # nonlocal x # toggle the comment hash to see the difference
        x = 'nonlocal'
        print('inner: ', x)
        
    inner()
    print('outer: ', x)
    
outer()
#1 - start with local
#2 - Parent local?
#3 - Global
INFO