Ele*_*naT 13 python methods comparison default
在python 文档中(是的,我在文档中有这个东西)它说:
用户定义的类默认具有
__cmp__()和__hash__()方法; 与它们一起,所有对象都比较不等(除了自己)和x.__hash__()返回id(x).
但是下面的代码显示了另一件事:
>>> class Test(object): pass
...
>>> t = Test()
>>>
>>> t.__hash__
<method-wrapper '__hash__' of Test object at 0x01F2B5D0>
>>>
>>> t.__cmp__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Test' object has no attribute '__cmp__'
>>>
Run Code Online (Sandbox Code Playgroud)
那么__cmp__我错过了哪里或什么?