Unhashable type Position *Edit: This is for Python


#1

I was trying to put my get_surrounding_cardinals() into a dictionary as keys, and it kept returning an error:
“Type Position unhashable:”

To fix this you should add the following code to positionals.py, in the class Position at the end after eq is defined:

def hash(self):
return hash((self.x, self.y))

I hope it helps.
If I was the only one with this problem consider me as a newbie:P


#2

Sadly underscores in this forum will distort the code. You of course typed:

def __hash__(self):
    return hash((self.x, self.y))

#3

Yes, thank you. I did not notice that.