I'm developing a python project. My project folder structure looks something like this:
rootfolder
-- config folder (has config class which gives config object)
-- main folder1
-- sub folders
-- main folder2
-- sub folders
I have a main.py in my main folders which need config object. Also there are a lot of modules in my sub folders which needs access to config object. So currently, I'm instantiating config object in my main.py and passing config object to each of my sub modules. Is there a way to make my config object globally available to all modules? Something like environment variables.
I tried something like this in my main code:
config = Config.getConfig() # fetching config object which is of type dict
os.environ['config'] = config
But it does not work since os.environ will only take strings. Thanks in advance for the help!