Currently I am using json
to save a dict to a config file. I load this to turn it into a dict
then turn it into a SimpleNamespace
because I prefer dot notation to access the settings. To do this, I load it as in this example:
import json
from types import SimpleNamespace
SETTINGS = json.load(open("config.json", 'r'))
SETTINGS = SimpleNamespace(**SETTINGS)
However, as I am currently loading the dict
into a SimpleNamespace
it is not loading the sub dicts within the config file. So for example if I do:
SETTINGS.server_info.port
I get the error:
AttributeError: 'dict' object has no attribute 'port'
I was wondering how I load all dicts into the namespace as name spaces so that I am able to use dot notation all the way down the dictionary.