How are functions inside functions called? And can I access those functions or they work like “helper methods”?
问题 I'm studying Python through The Python Tutorial and I'm currently at Classes (chapter 9), but during the explanation of "scopes and namespaces" I got a question. The author give this example: def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spam = "nonlocal spam" def do_global(): global spam spam = "global spam" spam = "test spam" do_local() print("After local assignment:", spam) do_nonlocal() print("After nonlocal assignment:", spam) do_global() print(