Skip to content

Instantly share code, notes, and snippets.

@JorisPLA7
Last active October 31, 2019 15:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JorisPLA7/966bacf76c3a1f815c5fe55cee798dee to your computer and use it in GitHub Desktop.
Save JorisPLA7/966bacf76c3a1f815c5fe55cee798dee to your computer and use it in GitHub Desktop.
cloud global object
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()
@JorisPLA7
Copy link
Author

A cleaner way to set global variable, import this in your project.
Still not a good practice in a common situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment