【发布时间】:2019-03-18 20:57:39
【问题描述】:
我从 Learning Python(第 5 版)中读到(第 1364 页,第 40 章):
在 Python 2.X 中,新式类继承自 object,它是 type 的子类;经典类是 type 的实例,不是从类创建的。
然而,
issubclass(object, type)
给我
False
在 Python 2.7 中。
所以,作者似乎做了一个错误的陈述,即 object 是 type 的子类,还是我遗漏了什么?
【问题讨论】:
-
如果你尝试
issubclass(type(object), type)会怎样? -
"classic classes are instances of
type" 也是假的。
标签: python python-2.7 inheritance subclass metaclass