How can I access global variable inside class in Python
05:22 30 May 2012

I have this:

g_c = 0

class TestClass():
    global g_c
    def run(self):
        for i in range(10):
            g_c = 1
            print(g_c)

t = TestClass()
t.run()

print(g_c)

how can I actually modify my global variable g_c?

python scope global