class McItems(dict): attrs = ["guid"] def as_dict(self): return self.__dict__ def from_dict(self, *val, **kwargs): for key in val: setattr(self, key, val[key]) for key in kwargs: setattr(self, key, kwargs[key]) def from_dict_selected(self, *val, **kwargs): if len(self.attrs) == 1: raise "overwrite for McItems has to have attrs with list of more than one item" for key in val: if key in val.attrs: setattr(self, key, val[key])