I am facing issues adding class attributes dynamically from a list of strings, consider the following scenario:
This is my class:
class Customer(object):
def __init__(self,**kw):
self.__dict__ = kw
def add_attributes(self,**kw):
self.__dict__.update(kw)
#a group of attributes i want to associate with the class
list = []
list.append("name")
list.append("age")
list.append("gender")
Customer c
for i in list:
# i is the attribute name for the class
c.add_attributes( i = "test")
The issue seems to be the fact that it is treating the attribute name as a string, can someone please advise