def func(): x = True class C: def method(self): nonlocal x x = False