order independent hash?

88888 Dihedral dihedral88888 at googlemail.com
Thu Dec 1 11:17:08 EST 2011


On Thursday, December 1, 2011 11:52:46 PM UTC+8, Dave Angel wrote:
> On 12/01/2011 10:35 AM, 88888 Dihedral wrote:
> > On Wednesday, November 30, 2011 8:47:13 PM UTC+8, Peter Otten wrote:
> >> Neal Becker wrote:
> >>
> >>> I like to hash a list of words (actually, the command line args of my
> >>> program) in such a way that different words will create different hash,
> >>> but not sensitive to the order of the words.  Any ideas?
> >> You mean a typical python hash value which would be /likely/ to differ for
> >> different lists and /guaranteed/ to be equal for equal lists is not good
> >> enough? Because that would be easy:
> >>
> >> args = sys.argv[1:]
> >> hash(tuple(sorted(args))) # consider duplicate args
> > I knew a hash can replace a bi-directional linked list.
> > The value  can be a multi-field string  to be parsed for further actions.
> > Is this what you are asking?
> A hash is a number, so I don't see how it can replace any kind of linked 
> list.  Perhaps you're thinking of some other language.
> 
> -- 
> 
> DaveA

A long number of a varied length allowed but   can interpreted by the programmer. 





More information about the Python-list mailing list