[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: objects as mutable dictionary keys
From:       "Andrew Koenig" <ark () acm ! org>
Date:       2004-12-27 23:32:47
Message-ID: zY0Ad.39142$uM5.37866 () bgtnsc05-news ! ops ! worldnet ! att ! net
[Download RAW message or body]

"Peter Maas" <peter@somewhere.com> wrote in message 
news:33bi4tF3u4cilU1@individual.net...

> This leads to the question:
>
> Why does (t1 == t2 => d[t1] identical to d[t2]) hold for user defined
> objects and not for lists? My answer: because the cmp function looks at
> id() for user defined objects and at list content for lists.

Yes.

> Why does the cmp function _have_ to look at lists contents?
> My answer: because of the existence of list literals.

No.  The reason is that lists are containers, and it it is reasonable to 
define container equality recursively as element equality.  There are no set 
literals, but that doesn't mean that set equality should be identity.


-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic