set of sets

Paolino paolo_veronelli at
Thu Aug 11 13:39:49 CEST 2005

Matteo Dell'Amico wrote:
> Paolino wrote:
>>I thought rewriting __hash__ should be enough to avoid mutables problem 
>>class H(set):
>>  def __hash__(self)
>>    return id(self)
>>the add succeeds
>>the remove fails eventually not calling hash(s).
> Why don't you just use "frozenset"?
This is what I'm doing, but the problem remains IMO.
Anyway with frozenset I have to override __new__ instead of __init__ to 
make the initialization which is an operation not described in the 
frozenset  docs, which  makes subclassing frozenset a different operation.

Thanks Paolino

Yahoo! Messenger: chiamate gratuite in tutto il mondo

More information about the Python-list mailing list