python - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


convert/python

convert to Python expression

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

convert(expr, python)

Parameters

expr

-

expression to convert

Description

• 

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

Examples

The convert command leaves this list unchanged as it can already be used with EvalFunction.

> 

convert⁡1,5,7,python

1,5,7

(1)
> 

Python:-EvalFunction⁡len,1,5,7

3

(2)

This Vector is converted to an equivalent ndarray (NumPy n-dimensional array).

> 

pv≔convert⁡1,5,7,python

pv≔<Python object: [1 5 7]>

(3)
> 

type⁡pv&comma;python

true

(4)

This table is converted to a Python dictionary.

> 

T≔table⁡dog=canine&comma;cat=feline

T≔table⁡cat=feline&comma;dog=canine

(5)
> 

pd≔convert⁡T&comma;python

pd≔<Python object: {'cat': 'feline', 'dog': 'canine'}>

(6)
> 

type⁡pd&comma;python

true

(7)

Compatibility

• 

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