Hashable, immutable
From a recent SO question (see Create a dictionary in python which is indexed by lists) I realized I probably had a wrong conception of the meaning of hashable and immutable objects in python.
From a recent SO question (see Create a dictionary in python which is indexed by lists) I realized I probably had a wrong conception of the meaning of hashable and immutable objects in python.
I am trying to understand the Python hash function under the hood. I created a custom class where all instances return the same hash value.
For caching purposes I need to generate a cache key from GET arguments which are present in a dict.
This code is supposed to hash a password with a salt. The salt and hashed password are being saved in the database. The password itself is not.
I am writing a simple Python program.
Windows XP, Python 2.5:
I saw an example of code that where hash function is applied to a tuple. As a result it returns a negative integer. I wonder what does this function do? Google does not help. I found a page that explains how hash is calculated but it does not explain why we need this function.
TypeError: unhashable type: ‘dict’
What methods need to be overridden/implemented when making user-defined classes sortable and/or hashable in python?