Skip to content

Instantly share code, notes, and snippets.

@adrianmarkperea
Last active October 13, 2019 16:23
Show Gist options
  • Save adrianmarkperea/4b1ed423e46598d993777b9999e221e8 to your computer and use it in GitHub Desktop.
Save adrianmarkperea/4b1ed423e46598d993777b9999e221e8 to your computer and use it in GitHub Desktop.
def foo():
i_am_non_local = 5
def bleep():
i_am_non_local = 10
def oof():
nonlocal i_am_non_local
i_am_non_local = 20
def bop():
global i_am_non_local
i_am_non_local = 30
bleep()
print('After bleep:', i_am_non_local)
oof()
print('After oof:', i_am_non_local)
bop()
print('After bop:', i_am_non_local
foo()
print('Globally:', i_am_non_local)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment