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 =
similar to using a dict, you could just use kwargs like so:
class Person: def __init__(self, **kwargs): self.properties = kwargs def get_property(self, key): return self.properties.get(key, None) def main(): timmy = Person(color = 'red') print(timmy.get_property('color')) #prints 'red'