class Test:
    var1 = 'Cheese'
var2 = 'Toast'
dic = {}
dic['var1'] = 'NewCheese'
dic['var2'] = 'NewToast'
oTest = Test()
for key in list(dic.keys()):
    setattr(oTest, key, dic[key])
print('Var1 = ', oTest.var1)
print('Var2 = ', oTest.var2)
Looping through dictionary to insert value to an object