Python
EvalFunction
evaluate a Python function
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
EvalFunction(f,arg1,arg2,...)
EvalFunction(f,arg1,arg2,...,opts)
f
-
string or Python object
argN
(optional); arguments to the function call
opts
(optional) zero or more options as specified below
output = one of maple,python, or none
Specifies the output the evaluation should produce.
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).
The EvalFunction command executes a function, f(arg1,arg2,...) using the Python interpreter.
For information about controlling the output and automatic conversions to Maple data structures, see the documentation for the output option.
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](..).
with⁡Python:
ImportModule⁡math
EvalFunction⁡math.sin,1.0
0.841470984807897
mathsin≔EvalString⁡math.sin
mathsin≔<Python object: <built-in function sin>>
mathsin⁡1.0
r≔EvalFunction⁡math.sin,1.0,output=python
r≔<Python object: 0.8414709848078965>
EvalFunction⁡abs,r
The Python[EvalFunction] command was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
See Also
Python:-EvalString
type/python
Download Help Document