Fix Python – Set attributes from dictionary in python
Is it possible to create an object from a dictionary in python in such a way that each key is an attribute of that object?
Something like this:
d = { ‘name’: ‘Oscar’, ‘lastName’: ‘Reyes’, ‘age’:32 }
e = Employee(d)
print e.name # Oscar
print e.age + 10 # 42
I think it would be pretty much the inverse of this question: Python dictionary fr….