Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

variable inside class not detecting global variable in python

some_global_variable

class TestClass():
    def run(self):
        #we can access it by defining the variable as global inside the function
        global some_global_variable 
        for i in range(10):
            some_global_variable = 1
            print(some_global_variable)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #variable #class #detecting #global #variable #python
ADD COMMENT
Topic
Name
4+3 =