I have been trying to use some of my python code in sage but
have been having problems, apparently because sage implements
generic arithmetic differently to python.

Here is a simple example:

class MyList(list):

    def __rmul__(self, other):
        return MyList([other*x for x in self])

Python:
>>> x = MyList([1,2,3])
>>> 10*x
[10, 20, 30]

Sage:

sage: x = MyList([1,2,3])
sage: 10*x
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call
last)

/home/gbunting/algebra/comp/python/sage/<ipython console> in
<module>()

/home/gbunting/algebra/comp/python/sage/element.pyx in
element.RingElement.__mul__()

/home/gbunting/algebra/comp/python/sage/element.pyx in
element.bin_op_c()

<type 'exceptions.TypeError'>: unsupported operand parent(s) for '*':
'Integer Ring' and '<class '__main__.MyList'>'


I have python code for that I use for experimenting with polynomials
and
differential operators and would like to use it from sage.

Cheers,
Gary


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to