Last active
October 31, 2019 15:49
-
-
Save JorisPLA7/966bacf76c3a1f815c5fe55cee798dee to your computer and use it in GitHub Desktop.
cloud global object
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
class globalizer(): | |
def __init__(self): | |
global a | |
a = self #global self formbidden bcs self is an ARGUMENT | |
cloud = globalizer() | |
if __name__ == '__main__': | |
cloud.nbr = 1 | |
cloud.string = 'Hello World' | |
def randFunction(): | |
for i in range(cloud.nbr): | |
print(cloud.string) | |
randFunction() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A cleaner way to set global variable, import this in your project.
Still not a good practice in a common situation.