dictionary keys, __hash__, __cmp__

Jan-Erik Meyer-Lütgens python at meyer-luetgens.de
Wed Nov 5 15:03:19 CET 2003


Michael Hudson wrote:
> Jan-Erik Meyer-Lütgens  <python at meyer-luetgens.de> writes:
>>
>>    3. "If a class does not define a __cmp__() method it
>>        should not define a __hash__() operation either."
>>
>>
>>Can I asume that:
>> 
>>  -- I can savely ignore the 3rd statement, because python
>>     falls back to cmp(id(obj1), id(obj2)), if __cmp__()
>>     is not defined.
> 
> 
> Don't understand.
> 

Ok, let me ask the following question: What is the reason
for that rule?


-- 
Jan-Erik





More information about the Python-list mailing list