I have python project in 1 file. There is 5 classes in file. The classes uses global variables, which stores configs of all project.
I want refactoring my project, and have write out all variables in cfg file. Then i parse the file with ConfigObj python parser.
Now, how can i dispose of global variables in the classes in "true python way"? Does i need use something like programming pattern? Or, maybe, place all variables in one class, which named "setting", and use it everywhere?
Example of my code:
global_var_1 = 1
global_var_2 = 2
global_var_3 = 3
global_var_4 = 4
global_var_5 = 5
global_var_6 = 6
class First():
def method1():
global global_var_1, global_var_3
pass #some code here
def method2():
global global_var_1, global_var_6
pass #some code here
def method3():
global global_var_2, global_var_3
pass #some code here
#........
class Second():
def method1():
global global_var_5
pass #some code here
def method2():
global global_var_4, global_var_6
pass #some code here
def method3():
global global_var_1, global_var_3
pass #some code here
#.........
#And some other classes...
global_var_3 = 4
#and some other "global" code