代码片段一
class F(object): _b = ['d','a','b','c'] def __init__(self, **kwargs): for i in kwargs.iteritems(): if i[0] in self._b: self.__dict__[i[0]] = i[1] else: raise AttributeError("error") f = F(c=33, a=1,b=2, d=445) print f.a print f.b print f.d print f.c print dir(f)