set of sets

Matteo Dell'Amico della at toglimi.linux.it
Thu Aug 11 06:25:19 EDT 2005


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).

Why don't you just use "frozenset"?

-- 
Ciao,
Matteo



More information about the Python-list mailing list