Re: set of sets

2005-08-11 Thread Paolo Veronelli
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

Re: set of sets

2005-08-11 Thread Paolo Veronelli
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

deriving from str

2004-12-23 Thread Paolo Veronelli
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])