Python - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Connectivity : Python : Python/EvalFunction

Python

  

EvalFunction

  

evaluate a Python function

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

EvalFunction(f,arg1,arg2,...)

EvalFunction(f,arg1,arg2,...,output=mode )

Parameters

f

-

string or Python object

argN

-

(optional); arguments to the function call

mode

-

(optional); identical(maple,python,none)

Description

• 

The EvalFunction command executes a function, f(arg1,arg2,...) using the Python interpreter.

• 

By default the value returned is converted into a Maple data structure.  If no conversion is available, the return value will be an expression of type python, a Python object reference that can be used in subsequent calls to Python.

  

To avoid Maple conversions of the return value and always get a Python object, use the option, output=python.

  

To avoid all conversions, and omit the return value, use the option, output=none.

• 

If you have a callable python object, f, you can use ordinary Maple function syntax to call it f(a,b,c).  

• 

This function is part of the Python package, so it can be used in the short form EvalFunction(..) only after executing the command with(Python). However, it can always be accessed through the long form of the command by using Python[EvalFunction](..).

Examples

withPython:

ImportModulemath

EvalFunctionmath.sin,1.0

0.841470984807897

(1)

mathsinEvalStringmath.sin

mathsin<Python object: <built-in function sin>>

(2)

mathsin1.0

0.841470984807897

(3)

rEvalFunctionmath.sin&comma;1.0&comma;output=python

r<Python object: 0.8414709848078965>

(4)

EvalFunctionabs&comma;r

0.841470984807897

(5)

Compatibility

• 

The Python[EvalFunction] command was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

Python

Python:-EvalString

type/python