
python – 类,dict,self,init,args?
class attrdict(dict): def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = selfa = attrdict(x=1, y=2)print a.x, a.yb = attrdict()b.x, b.y
class attrdict(dict): def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = selfa = attrdict(x=1, y=2)print a.x, a.yb = attrdict()b.x, b.y