Skip to content

Instantly share code, notes, and snippets.

@JorisPLA7
Last active Oct 31, 2019
Embed
What would you like to do?
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

JorisPLA7 commented Apr 4, 2019

Just a personnal note for global objects

@JorisPLA7
Copy link
Author

JorisPLA7 commented Oct 31, 2019

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