Notes on Code Translation to Python
This help page describes details particular to code translation using the CodeGeneration[Python] function. For general information applicable to all the functions in the CodeGeneration package, see CodeGeneration/Details.
The Python code generated by CodeGeneration[Python] is valid for Python 3 as defined by the Python Language Specification.
In addition to the functions listed on the CodeGeneration/Details help page, the following Maple functions are recognized by CodeGeneration[Python]: cat, ceil, floor, and if (operator form).
Many basic math functions, recognized by CodeGeneration[Python], are translated to functions in the math library. Maple functions for linear algebra and special functions are translated to their equivalents in the numpy and scipy libraries.
As there are multiple Python libraries offering translations for core Maple functions, it may be necessary to specify a preferred library order with the libraryorder option (see CGOptions) to exert control over which Python libraries are used for the translation.
CodeGeneration[Python] translates printf statements to its own printf.out calls, but performs only limited analysis of the printf format string. Thus, some formatting instructions (for example, precision for floats) may be ignored in translation.
Ranges of Maple lists and Arrays are adjusted so that the resulting Python lists start with index 0.
Download Help Document
What kind of issue would you like to report? (Optional)