现在的位置: 首页 > 综合 > 正文

python创建只读属性对象的方法(ReadOnlyObject)

2013年06月21日 ⁄ 综合 ⁄ 共 187字 ⁄ 字号 评论关闭

复制代码 代码如下:
def ReadOnlyObject(**args):
dictBI = {}
args_n = []
for name, val in args.items():
dictBI[name] = val
args_n.append(name)
dictBI['__slots__'] = args_n
return type('ReadOnlyObject', (object,), dictBI)()

抱歉!评论已关闭.