set of sets

Paolino paolo_veronelli at tiscali.it
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 
>>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"?
> 
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 
http://it.beta.messenger.yahoo.com



More information about the Python-list mailing list