Setting Instance variables
I have two lists:
var_names = ['var1', 'var2', 'var3']
var_values = [1, 2, 3]
Could also be dict:
dict = {'var1': 1, 'var2':2, 'var3':3}
I am actually getting them from pandas, but getting from there to dict is generic and easy.
These list of instance variables have changing length but as part of the instantiation of a class i want to add them to the instance variables. E.g. for lists given above
self.var1 = var_values[0]
self.var2 = var_values[1]
self.var3 = var_values[2]
Could have similar code if the variable names and values were in a dict. Think i used setattr about a year ago, but I cant figure it out now. Any pointers. Just getting to junk using search