代码如下:
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)()
A programmer’s note boke for work and life
代码如下:
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)()