In Python, dictionaries are good to store and retrieve data. So, recently I discovered something called Hashable data types and it can be used as dictionary key values.
Below there two code snippets and first one working but the second one is not working.
I would like know what are the Hashable Data Types in Python? and How Python handles hashing basically (not the hashing algorithm but the logic beneath it)?
Code 1:
testDict = {["someArg", 35]: "someValue"}
print(testDict[["someArg", 35]])
Output 1:
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
Code 2:
testDict = {("someArg", 35): "someValue"}
print(testDict[("someArg", 35)])
Output 2:
"someValue"
What makes Python to act different to these two iterable data types? How can I understand if a data type is Hashable or not?
I'm using Python 3.7.0.
Thanks!