Set up a variable in the module will work as a global variable you can define multiple variables in the class. The reason for this is that python treats classes as modules.
Python global multiple variables example
Simple example code defines multiple global variables from inside a class.
This is the best way to set up a list of global variables would be to set up a class for them in that module. You can call them, update them, etc. in any other function by referencing them as such:
class globalBS(): bsA = "a" bsB = "b"
from main import globalBS print(globalBS.bsA) globalBS.bsB = "Hello" print(globalBS.bsB)
global statement does not create variables. It just makes Python look for them in the global namespace instead of the local namespace.
Do comment if you have any doubts and suggestions on this Python variable tutorial.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.