I came across the following piece of code:
def func(self, v: Tuple[Hashable]):
...
I know v: Tuple
would mean variable v must be of type Tuple, but what does Tuple[Hashable]
mean? Isn't a tuple in Python always hashable?
A tuple is only hashable if the values in the tuple are hashable themselves.
>>> hash((1,2))
-3550055125485641917
>>> hash(([1],2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With