2

我正在尝试查找有关 Python 基类的更多信息:object但找不到任何信息。它只是类似class object: pass并且不值得更多关注还是......?

我在哪里可以找到更多关于它的信息。其他类从它继承什么?

4

2 回答 2

3

这里有一些很好的信息(以及从那里链接的其他文章)。这是图表:

在此处输入图像描述

于 2012-05-21T12:24:21.247 回答
2

一些基本的东西供其他对象使用。

>>> dir(object())
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', 
'__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', 
'__setattr__', '__sizeof__', '__str__', '__subclasshook__']

有关这些方法的更多信息,请查看http://docs.python.org/reference/datamodel.html,以下是它们的实现方式http://hg.python.org/cpython/file/3d4d52e47431/Objects/对象.c

于 2012-05-21T12:23:18.773 回答