您可以
MyObject使用3个参数的调用来
type动态创建:
type(name, bases, dict) Return a new type object. This is essentially a dynamic form of the class statement...
例如:
mydict={'__tablename__':stored['tablename'], '__table_args__':{'autoload':True},}MyObj=type(stored['objectname'],(base,),mydict)print(MyObj)# <class '__main__.MyObject'>print(MyObj.__base__)# <class '__main__.base'>print(MyObj.__tablename__)# my_internal_table_nameprint(MyObj.__table_args__)# {'autoload': True}


