为什么'issubclass(object,type)'给出false(在python中)? [英] Why 'issubclass(object, type)' gives false (in python)?
问题描述
我对python类层次结构感到困惑。
I'm confused in python class hierarchy.
我想知道类型和对象之间的关系。
I want to know the relation between type and object.
object是'issubclass()'函数的顶部。
类型是事物的顶部。类和类型(事物)。 (为了避免混淆,我故意不再使用对象这个词。而是使用了东西。)
object is the top of 'issubclass()' function. type is the top of 'thing.class' and 'type(thing)'. (I intentionally didn't use the word object again to avoid confusion. instead I used thing.)
令人惊讶的是isinstance(object,type)和isinstance(type,object)都返回true。
Surprisingly isinstance(object, type) and isinstance(type, object) both return true.
详细解释层次结构。谢谢
Explain the hierarchy in detail. Thanks
我的意思是第一个写的是谁?类型?还是对象?
I mean which one was written first? type? or object?
推荐答案
在Python中,一切都是对象,所以:
In Python, everything is an object, so:
isinstance(type, object) == True
由于 object
是类型构造函数,因此它是 type
的子类:
Since object
is a type constructor, it's a subclass of type
:
isinstance(object, type) == True
这篇关于为什么'issubclass(object,type)'给出false(在python中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!