In Python 2.x, all new-style classes inherit from object
implicitly or explicitly. Then look at this:
>>> class M(type):
... pass
...
>>> class A:
... __metaclass__ = M
...
>>> class B:
... pass
...
>>> a = A()
>>> b = B()
>>> type(A)
<class __main__.M >
>>> type(a)
<class __main__.A >
这是否意味着<代码>A? 但是,A
> 不适用。 任何途径、权利?
>>> type(B)
<class classobj >
>>> type(b)
<type instance >
缩略语
>>> isinstance(A, object)
True
>>> isinstance(B, object)
True
why are instances of both A
and B
instances of object
?
如果B
是object
的一个实例,则type(B)
?