#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Review of namespaces, global, nonlocal """ def scope_test() -> None: def do_local() -> None: thing = "local thing" def do_nonlocal() -> None: nonlocal thing thing = "nonlocal thing" def do_global() -> None: global thing thing = "global thing" thing = "enclosing thing" do_local() print("After local assignment:", thing) do_nonlocal() print("After nonlocal assignment:", thing) do_global() print("After global assignment:", thing) scope_test() print("In global scope:", thing)