On 2015-03-04 15:18, Simon King wrote:
No. If a Python class has just *some* __add__, then the coercion framework
is out of the game. It must be sage.structure.element.ModuleElement.__add__,
or it won't work. Example:
sage: from sage.structure.element import ModuleElement
sage: class MyClass(ModuleElement):
....: def __add__(self, other):
....: print "no coercion is involved"
....: return self
....: def _add_(self, other):
....: print "we got coercion"
....: return self
....:
sage: E = MyClass(ZZ)
sage: E+E
no coercion is involved
Generic element of a structure
I admit I got confused myself.
Anyway, continuing the above example:
sage: E += E
we got coercion
The fact that __iadd__ calls _add_ would be analogous to __richcmp__
calling _cmp_ instead of __cmp__. And that is what I want to do.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.