I have the following class that returns the dictionary given the kwargs
as an input.
class Emp_Constant:
def __init__(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
However, in some instances, I would like to pass the dictionary as an input to this class and access the key values as variables.
For example, if my dictionary is {'name': 'Tome', 'age':'26'}
, then
I would like to access 'Tom' as below:
set = {'name': 'Tom', 'age':'26'}
a = Emp_Constant(set)
first_emp = a.NAME (where NAME is a variable that holds value of key 'name')
Is this possible to achieve?