python创建只读属性对象的方法(ReadOnlyObject)
(编辑:jimmy 日期: 2024/11/27 浏览:3 次 )
复制代码 代码如下:
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)()
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)()
下一篇:centos下更新Python版本的步骤