Let's say I have a dictionary:
>>> d = {}
It has a method clear()
:
>>> d.clear
<built-in method clear of dict object at 0x7f209051c988>
... which has a __hash__
attribute:
>>> d.clear.__hash__
<method-wrapper '__hash__' of builtin_function_or_method object at 0x7f2090456288>
... which is callable:
>>> callable(d.clear.__hash__)
True
So why can't I hash it?
>>> hash(d.clear)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
Note: I know that dict
objects are unhashable – I'm curious as to why this restriction extends to their methods, even though, as noted above, they appear to claim otherwise?