class Bar(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
>>> bar = Bar(a=1, b=2)
>>> bar.a
1
allowed_keys = ['a', 'b', 'c']
self.__dict__.update((k, v) for k, v in kwargs.iteritems() if k in allowed_keys)
class Bar(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
>>> bar = Bar(a=1, b=2)
>>> bar.a
1
allowed_keys = ['a', 'b', 'c']
self.__dict__.update((k, v) for k, v in kwargs.iteritems() if k in allowed_keys)