"Nick Coghlan" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> Although, it looks like new-style classes currently don't apply this 
> rule - you get the default hash implementation from object no matter 
> what:
>
> Py> class NotHashable(object):
> ...   def __cmp__(self, other):
> ...     return 0
> ...
> Py> hash(NotHashable())
> 10297264
> Py> d = {NotHashable(): "Hi"}
> Py> d
> {<__main__.NotHashable object at 0x009D1FF0>: 'Hi'}
>
> That may be a bug rather than a feature :)


It does seem to conflict with the doc you quoted elsewhere in this thread:
http://www.python.org/dev/doc/devel/ref/customization.html
3.3.1 Basic customization
__hash__:
 if it defines __cmp__() or __eq__() but not __hash__(), its instances will 
not be usable as dictionary keys.

Assuming your test is with 2.4, I'd submit a bug report noting the 
discrepancy.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to