class AllMyFields:

    def __init__(self, dictionary):
        for k, v in list(dictionary.items()):
            setattr(self, k, v)
o = AllMyFields({'a': 1, 'b': 2})
o.a
Creating class instance properties from a dictionary in Python