Skip to content

Instantly share code, notes, and snippets.

@dandye
Last active December 15, 2015 07:29
Show Gist options
  • Save dandye/5223948 to your computer and use it in GitHub Desktop.
Save dandye/5223948 to your computer and use it in GitHub Desktop.
global can be declared anywhere in function
def make_global():
global x
x = 1
def some_func():
print x,
def main():
make_global()
some_func()
x = 2
some_func()
global x
x = 3
some_func()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment