The best way to share global variables across modules across a single program is to create a config module. Just import the config module in all modules of your application; the module then becomes available as a global name.
config.py
x = 0
mod.py:
import config
config.x = 1
main.py:
import config
import mod
print(config.x)
Hope it works!!
If you are a beginner and need to know more about Python, It's recommended to go for Python Certification course today.
Thanks!