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 i
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
I want to add some methods to str class ,but when I change the __init__
methods I break into problems
class Uri(str):
def __init__(self,*inputs):
print inputs
if len(inputs)>1:
str.__init__(self,'<%s:%s>'%inputs[:2])