Of course there should be no global variables - vars should be passed with function calls. My actual implementation needs lots of variables which are used in different "xxx.py" modules. So I tried to make an own class including these variables and put it in an own module named e.g. "vars.py":
class GlobalVariables():
def __init__():
self.a = 42
self.e = 2.71828
self.c = ["good","music"]
# ---> should I place:
gv = GlobalVariables() # (1)here
The main program would look like for this case (1)
from vars.py import gv
def main():
gv.a = 73
...
and in case (2)
from vars.py include GlobalVariables
gv = GlobalVariables() # (2)in the main program
def main():
gv.b = 2.71828
...
I prefer the first method, since gv is used in many separate modules. Defining gv in each module separately there are certainly different gv variables in each module.
Reading lots of instructions and posts about classes and global variables I got confused which way is applicable - or is there a completely different approach to this problem?