class attrdict(dict):

    def __getattr__(self, k):
        return self[k]

def __setattr__(self, k, v):
    self[k] = v
somedict = {'key': 123, 'stuff': 456}
data = attrdict(somedict)
print(data.key)
print(data.stuff)
Turn the dictionary keys into variable names with same values in Python from .mat Matlab files using scipy.io.loadmat