Hi Javier, On 7 Dez., 10:16, Simon King <simon.k...@uni-jena.de> wrote: > But in both cases, it is also assumed that you are using coercion. > Hence, when the test "self==None" raises an error or returns a wrong > result then it could also be that there is a wrong coercion.
Ouch, sorry, I thought that your conjugacy classes are the *elements* of some parent. But after a brief look at your code, I see that a conjugacy class *is* a parent. So, forget what I said in my previous post: That was about elements. For parents, you simply implement a __cmp__ method (or perhaps __richcmp__), but you must not make any assumption on the type of the second argument. It is generally expected in Python that a comparison will *never* raise an exception, and you need to write your __cmp__ accordingly. Often, you would write stuff like this: sage: class MyParent(Parent): ....: def __init__(self,n): ....: self._n = n ....: Parent.__init__(self) ....: def __cmp__(self,other): ....: c = cmp(type(self),type(other)) ....: if c: ....: return c ....: # By now, you know that "other" has the right type ....: return cmp(self._n,other._n) ....: sage: P1 = MyParent(1) sage: P2 = MyParent(2) sage: P1<P2 True sage: P2<P1 False sage: P2==None False sage: P1==None False Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org