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

Posted in 未分类

发表评论