__get__
函数 -
slot_tp_descr_get
和wrap_descr_get
。它们与以下命令相关 -
TPSLOT(__get__, tp_descr_get, slot_tp_descr_get, wrap_descr_get,
"__get__($self, instance, owner=None, /)\n--\n\nReturn an attribute of instance, which is of type owner.")
wrap_descr_get
是包装slot_tp_descr_get
的包装函数。通过
slot_tp_descr_get
的代码,我发现它称为
__get__
参数的
self
。因此,如果传递自己的类型的对象,它会无限地运行吗? IF语句前提的函数中有一个返回语句,但我认为它不会运行。因为,“如果子句”检查self
是否实现了
__get__
的类,则由于我们通过了此类的一个对象,因此会找到
__get__
.。
相关问题
如果我称其他类别(如函数类)为下面的其他类别。
__get__
是由def fun():
pass
type(fun).__get__
or
fun.__get__
__get__
wrap_descr_get
类(此处的包装器descriptor)并调用班级的
__get__
您把事情混在一起了。
“ wrapper_descriptor”类型,
__get__
是一种特定类型,其实例用于包装作为C插槽实现的方法。它与其他几种描述符类型一起实现。它的功能是
slot_tp_descr_get
,而不是您查看的任何功能。
types.WrapperDescriptorType