I have the following Python class:
class Test:
def __init__(self, ints: List[int]) -> None:
self.ints = ints
def __eq__(self, other: object) -> bool:
if not isinstance(other, Test):
return NotImplemented
return self.ints == other.ints
Because I've overridden the equals method, I should implement the hash method. However, lists are not hashable in Python.
I've read that I can convert the List
to a Tuple
and hash that, but this feels a bit hacky. Are there any better options?