object.__dict__ 和其他地方的隐藏方法设置为这样的事情:
<dictproxy {'__add__': <slot wrapper '__add__' of 'instance' objects>,
'__and__': <slot wrapper '__and__' of 'instance' objects>,
'__call__': <slot wrapper '__call__' of 'instance' objects>,
'__cmp__': <slot wrapper '__cmp__' of 'instance' objects>,
'__coerce__': <slot wrapper '__coerce__' of 'instance' objects>,
'__contains__': <slot wrapper '__contains__' of 'instance' objects>,
'__delattr__': <slot wrapper '__delattr__' of 'instance' objects>,
'__delitem__': <slot wrapper '__delitem__' of 'instance' objects>,
'__delslice__': <slot wrapper '__delslice__' of 'instance' objects>,
'__div__': <slot wrapper '__div__' of 'instance' objects>,
'__divmod__': <slot wrapper '__divmod__' of 'instance' objects>,
...
Run Code Online (Sandbox Code Playgroud)
这些是什么,它们用于什么?
编辑:这是从以下输出:
class A:
pass
b = A()
print(type(b).__dict__)
Run Code Online (Sandbox Code Playgroud)
它是一种内部类型,用于内置类上的一些可调用对象和方法。为什么它与函数或任何其他可调用函数不同并不重要。您可以将其作为对象上的方法调用,同样如此。