Is it possible to properly copy a class using type

﹥>﹥吖頭↗ 提交于 2019-12-04 07:09:09
internet_user

You could use type.__new__(type(cls), cls.__name__, cls.__bases__, dict(cls.__dict__)). This uses the normal type creation process, but creates an instance of type(cls) instead of type.

As for the __metaclass__ issue, I think that is because __metaclass__ is usually what is called, so type can't use it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!