Last active
December 15, 2015 07:29
-
-
Save dandye/5223948 to your computer and use it in GitHub Desktop.
global can be declared anywhere in function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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