标签:
class Model(dict):
__metaclass__ = ModelMetaclass
def __init__(self, **kw):
super(Model, self).__init__(**kw)
def __getattr__(self, key):
try:
return self[key]
except KeyError:
raise AttributeError(r"‘Dict‘ object has no attribute ‘%s‘" % key)
def __setattr__(self, key, value):
self[key] = value
标签:
原文地址:http://www.cnblogs.com/tiaowangzhe/p/4672900.html