Passing ‘Global Variable’ across the files in Python

Passing global variable – Attachment

I have encounter a situation where i need to pass a variable from one file to another file. This is like passing global variable across the files. I’ve created three files to demonstrate this as follows,

main.py   # name of the file
import subfile1
import subfile2
subfile1.globle_pas()
print(settings.x)
subfile2.change_glob_var()
print(settings.x)
subfile1.py     # name of the file
x = 0
def globle_pas():
global x
x = 1 # Default value of the ‘x’ configuration setting
subfile2.py     # name of the file
import settings
settings.globle_pas()
def change_glob_var():
settings.x = 9