Paolino wrote:
> I thought rewriting __hash__ should be enough to avoid mutables problem but:
> 
> class H(set):
>    def __hash__(self)
>      return id(self)
> 
> s=H()
> 
> f=set()
> 
> f.add(s)
> f.remove(s)
> 
> the add succeeds
> the remove fails eventually not calling hash(s).
> 

Yes this is really strange.

from sets import Set
class H(Set):
   def __hash__(self):
     return id(self)

s=H()
f=set() #or f=Set()

f.add(s)
f.remove(s)

No errors.

So we had a working implementation of sets in the library an put a 
broken one in the __builtins__ :(

Should I consider it a bug ?

Regards Paolino

                
___________________________________ 
Aggiungi la toolbar di Yahoo! Search sul tuo Browser, e'gratis! 
http://it.toolbar.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to