I have searched SO and found numerous questions about this very topic, and I've tried recreating accepted answers, but I am unable to duplicate the output shown.
>>> class testFoo(object):
... def __init__(self,x):
... self.x = x
... def __eq__(self, other):
... return hash(self.x) == other
... def __hash__(self):
... return hash(self.x)
...
>>> d = {}
>>> x = testFoo("a")
>>> d[x] = 1
>>> d
{<__main__.testFoo object at 0x7f6d9ccc5550>: 1}
>>> hash(x)
12416037344
>>> hash("a")
12416037344
>>>
What I expected to see when I typed "d" above is a key "a", not the repr string for the object. What am I doing wrong?