[Tutor] hash
Alan Gauld
alan.gauld at btinternet.com
Thu Jul 5 11:34:34 CEST 2007
"linda.s" <samrobertsmith at gmail.com> wrote
> what is the use of def __hash__(self)?
> I can not understand the document.
> any example?
First, do you understand what a hash is?
Do you want an example of writing a hash - see Andreas reply.
Or do you want to know when/how to use a hash?
As Andreas said the __hash__ method makes an object
hashable in the same way that the other __xxx__ methods
modify the standard operations/behaviours of the object.
Wikipedia has a good page on hash functions:
http://en.wikipedia.org/wiki/Hash_%28computer_science%29
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list