[Tutor] Hashing

charlie derr wrong@crosswinds.net
Fri, 10 Aug 2001 21:15:16 -0400


+-----Original Message-----
+From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
+Allan Crooks
+Sent: Friday, August 10, 2001 8:09 PM
+To: tutor@python.org
+Subject: [Tutor] Hashing
+
+
+Hi,
+
+Does anyone know exactly how the hash method derives a hash 
+for tuples? Or strings?
+
+>>> a, b, c, d = (1,), (2,), (3,), (4,)
+>>> map (hash, [a, b, c, d])
+[-1660579480, -1660579477, -1660579478, -1660579475]
+
+The above code does seem slightly bewildering to me, anyone got 
+any ideas?

no ideas, but i found something strange while playing around


>>> hash((0,))
-1660579479
>>> hash((-1,))
1660579479
>>> hash((-2,))
1660579479

aren't these values supposed to be unique?

	~c


+
+Allan.
+
+_______________________________________________
+Tutor maillist  -  Tutor@python.org
+http://mail.python.org/mailman/listinfo/tutor
+