Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There is a patch available that fixes this behaviour. If you want to apply the patch to get this working on your version of Sage, instructions are available.

Someone (other than me) needs to review the patch before it can be included in Sage by default.

In the meantime, if you don't want to go to the trouble of applying the patch, a quick and dirty solution would be to use sage_eval(mlist._sage_repr()):

sage: mlist = mathematica([[1,2,3],1])
sage: mlist
{{1, 2, 3}, 1}
sage: mlist._sage_repr()
'[[1, 2, 3], 1]'
sage: slist2 = sage_eval(mlist._sage_repr())
sage: slist2
[[1, 2, 3], 1]
sage: type(slist2)
<type 'list'>
sage: type(slist2[1])
<type 'sage.rings.integer.Integer'>

This approach will not work for symbolics - if you need to import things with symbolic variables, then it gets a little more complicated and you'd be better off using the patch linked above.