Python Unpack Kwargs Into Attributes
Python: Unpack **kwargs
into properties
I'm lazy. I want to be able to take any named arguments in my constructor call and make properties.
class DynConfig():
def __init__(self, *args, *kwargs):
self.__dict__.update(kwargs)
config = DynConfig(name='goliatone', age=99, email='goliat.one')
print config.name # goliatone
print config.age # 99
print config.url # goliat.one
Instead of doing this:
class DynConfig():
def __init__(self, name, age, email):
self.name = name
self.age = age
self.email = email