Re: Rich comparison methods don't work in sets?

2009-06-21 Thread Gustavo Narea
Hi, everyone. OK, I got it now! The value of the hash is not decisive, as __eq__ will still be called when the hashes match. It's like a filter, for performance reasons. It's really nice, I just tried it and it worked. Thank you very, very much!! Cheers, - Gustavo. -- http://mail.python.or

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Robert Kern
On 2009-06-20 18:22, Terry Reedy wrote: Gustavo Narea wrote: Hello again, everybody. Thank you very much for your responses. You guessed right, I didn't use the __hash__ method (and I forgot to mention that, sorry). And unfortunately, I think I can't make them hashable, because the objects are

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Terry Reedy
Gustavo Narea wrote: Hello again, everybody. Thank you very much for your responses. You guessed right, I didn't use the __hash__ method (and I forgot to mention that, sorry). And unfortunately, I think I can't make them hashable, because the objects are compared based on their attributes, whic

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Aaron Brady
On Jun 20, 9:27 am, MRAB wrote: > Gustavo Narea wrote: > > Hello again, everybody. > > > Thank you very much for your responses. You guessed right, I didn't > > use the __hash__ method (and I forgot to mention that, sorry). > > > And unfortunately, I think I can't make them hashable, because the >

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Robert Kern
On 2009-06-20 11:27, MRAB wrote: Gustavo Narea wrote: Hello again, everybody. Thank you very much for your responses. You guessed right, I didn't use the __hash__ method (and I forgot to mention that, sorry). And unfortunately, I think I can't make them hashable, because the objects are compar

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Gabriel Genellina
En Sat, 20 Jun 2009 12:50:41 -0300, Gustavo Narea escribió: Thank you very much for your responses. You guessed right, I didn't use the __hash__ method (and I forgot to mention that, sorry). And unfortunately, I think I can't make them hashable, because the objects are compared based on thei

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread MRAB
Gustavo Narea wrote: Hello again, everybody. Thank you very much for your responses. You guessed right, I didn't use the __hash__ method (and I forgot to mention that, sorry). And unfortunately, I think I can't make them hashable, because the objects are compared based on their attributes, whic

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Steven D'Aprano
Gustavo Narea wrote: > Hello again, everybody. > > Thank you very much for your responses. You guessed right, I didn't > use the __hash__ method (and I forgot to mention that, sorry). > > And unfortunately, I think I can't make them hashable, because the > objects are compared based on their att

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Gustavo Narea
Hello again, everybody. Thank you very much for your responses. You guessed right, I didn't use the __hash__ method (and I forgot to mention that, sorry). And unfortunately, I think I can't make them hashable, because the objects are compared based on their attributes, which are in turn other kin

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Aaron Brady
On Jun 19, 12:42 pm, Chris Rebert wrote: > On Fri, Jun 19, 2009 at 12:02 PM, Gustavo Narea wrote: > > Hello, everyone. > > > I've noticed that if I have a class with so-called "rich comparison" > > methods > > (__eq__, __ne__, etc.), when its instances are included in a set, > > set.__contains__/_

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Chris Rebert
On Fri, Jun 19, 2009 at 12:02 PM, Gustavo Narea wrote: > Hello, everyone. > > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements >

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Peter Otten
Gustavo Narea wrote: > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements > and thus > the code below: > """ > obj1 = RichComparis

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Matthew Wilson
On Fri 19 Jun 2009 03:02:44 PM EDT, Gustavo Narea wrote: > Hello, everyone. > > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements

Rich comparison methods don't work in sets?

2009-06-19 Thread Gustavo Narea
Hello, everyone. I've noticed that if I have a class with so-called "rich comparison" methods (__eq__, __ne__, etc.), when its instances are included in a set, set.__contains__/__eq__ won't call the .__eq__ method of the elements and thus the code below: """ obj1 = RichComparisonClass() obj2 = Ric