-1

Is there a better way to convert a Maple expression to Python than the provided convert function in Maple (which seems to not work at all)

convert(9 + x, python)
Error, (in convert/python) cannot convert to python
Peter Cotton
  • 1,671
  • 14
  • 17

1 Answers1

0

If you are trying to produce python source code from some Maple expression then see the CodeGeneration package.

For example,

CodeGeneration[Python]( 9+x );

  cg0 = 9 + x

And another,

func := proc(x) local y; y:=9+arcsin(x) end proc:

CodeGeneration[Python]( func );

  import math

  def func (x):
      y = 9 + math.asin(x)
      return(y)

The convert(...,python) syntax is for converting some kinds of Maple expression into an alternate internal representation that can be used with the (limited) python runtime emulation. But you've described producing python "code", which I take to mean source code for export.

acer
  • 6,671
  • 15
  • 15