अजगर docs (yeah, I have this thing with the docs) यह कहा गया है कि में:पायथन - उपयोगकर्ता द्वारा परिभाषित कक्षाओं में डिफ़ॉल्ट रूप से __cmp __() और __hash __() विधियां हैं? या?
उपयोगकर्ता-परिभाषित वर्गों डिफ़ॉल्ट रूप से
__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__'
>>>
तो जहां __cmp__
है या मैं क्या याद आ रही है?