Home Ask Login Register

Developers Planet

Your answer is one click away!

Fahim February 2016

How hash() function works in Python?

I cannot understand how hash() works in Python and in which cases would we need it.

a = int(raw_input())
b = tuple(map(int,raw_input().split()))

Here is a simple example using hash() and I would like someone to explain it to me.


sorin February 2016

hash is implemented in Python the same way as in other languages, nothing special about it.

Imagine that hash() takes an object and generates a really-big-number that is used in a way similar to a fingerprint, to quickly identity its owner.

Hashes are not universal, which means that the final result depends on the implementation, but you should not care about this too much.

Post Status

Asked in February 2016
Viewed 1,541 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life