python创建只读属性对象的方法(ReadOnlyObject)
脚本专栏 发布日期:2025/2/5 浏览次数:1
正在浏览:python创建只读属性对象的方法(ReadOnlyObject)
复制代码 代码如下:
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)()