#!/usr/local/bin/python3 xxx = 10 xx = 1000 class Foo: print(xxx) xx = 100 def foo(self): nonlocal xx print(xxx) print(xx) foo = Foo() foo.foo()