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

594次阅读  |  发布于5年以前

复制代码 代码如下:

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)()

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8