"Peter Maas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> This strikes me because if one can do this with instances of user
> defined classes why not with lists? Trying to use lists as dict
> keys yields "TypeError: list objects are unhashable". So why are
> list objects unhashable and user defined objects hashable? For
> user defined objects hash(x1) = id(x1), why not do the same
> with lists?

If d is a dict and t1 and t2 are tuples, and t1 == t2, then d[t1] and d[t2] 
are the same element.

If lists used the id as the hash, this property would not hold for lists.

Can you give me an example of a program for which you consider such behavior 
to be useful?


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to