convert/python
convert to Python expression
Calling Sequence
Parameters
Description
Examples
Compatibility
convert(expr, python)
expr
-
expression to convert
The convert(expr, python) command accepts a Maple expression and returns a result suitable to use as input for Python[EvalFunction].
In this conversion, numeric literals and strings are left as is, and container structures such as tables and Arrays are replaced with references to equivalent Python structures.
Conversion of the following types is supported:
Array
complex(extended_numeric)
DataSeries
list
Matrix
set
string
table
Vector
The convert command leaves this list unchanged as it can already be used with EvalFunction.
convert⁡1,5,7,python
1,5,7
Python:-EvalFunction⁡len,1,5,7
3
This Vector is converted to an equivalent ndarray (NumPy n-dimensional array).
pv≔convert⁡1,5,7,python
pv≔<Python object: [1 5 7]>
type⁡pv,python
true
This table is converted to a Python dictionary.
T≔table⁡dog=canine,cat=feline
pd≔convert⁡T,python
pd≔<Python object: {'dog': 'canine', 'cat': 'feline'}>
type⁡pd,python
The convert/python command was introduced in Maple 2020.
For more information on Maple 2020 changes, see Updates in Maple 2020.
See Also
convert
Python
type/python
Download Help Document