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

List:       python-list
Subject:    Re: objects as mutable dictionary keys
From:       Peter Maas <peter () somewhere ! com>
Date:       2004-12-27 23:04:40
Message-ID: 33birhF3uh8e1U1 () individual ! net
[Download RAW message or body]

Steven Bethard schrieb:
> If lists were hashable, new programmers to Python would almost certainly 
> make mistakes like:
> 
> py> d = {[1, 2, 3]: 'abc'}

 > The coder here almost certainly *doesn't* want that list to be compared
 > by id.  The only way to get a binding for that list would be using the
 > dict's keys or __iter__ methods.

That's what I meant when I said that for lists id() doesn't make sense
as hash because of the list literals.

For user defined objects id() can be used as hash because there are
no literals for user defined objects.

-- 
-------------------------------------------------------------------
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
-------------------------------------------------------------------
-- 
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