def _declarative_constructor(self, **kwargs):
 cls_ = type(self)
 for k in kwargs:
  if (not hasattr(cls_, k)):
   raise TypeError(('%r is an invalid keyword argument for %s' % (k, cls_.__name__)))
  setattr(self, k, kwargs[k])

def _declarative_constructor ( self , ** kwargs ) : cls_ = type ( self ) for k in kwargs : if ( not hasattr ( cls_ , k ) ) : raise TypeError ( ( '%r is an invalid keyword argument for %s' % ( k , cls_ . __name__ ) ) ) setattr ( self , k , kwargs [ k ] )
a simple constructor that allows initialization from kwargs .