evalpythonfunction
Evaluates a Python function using its correspondent input arguments.
[status,errorMessage, out1, out2, ... outM] = evalpythonfunction(fileName, pythonFunctionName, Arg1, Arg2, ..., ArgN)
Inputs
- fileName
- A fully qualified Python file name. Can be an empty string if function is known in Python global name space.
- pythonFunctionName
- Any valid Python function name.
- Arg1, Arg2, ..., ArgN
- Inputs argument(s) to Python function. These arguments are equal to number of arguments that the Python function accepts.
Outputs
- status
- Status of the script executed.
- 1
- success
- 0
- failure
- errorMessage
- Error message indicating the failure.
- out1, out2, ... outM
- Output from Python function. These are equal to number of output Python function returns.
Example
Example 1 - evalpythonfunction example, calling function with no input arguments and no return values.
[status,errorMessage]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_1')
status = 1
errorMessage =
Example 2 - evalpythonfunction example, calling function with input arguments and no return values.
x=9;
y=99;
[status,errorMessage]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_2',x,y)
status = 1
errorMessage =
Example 3 - evalpythonfunction example, calling function with input arguments and return values.
x1=9;
y1=99;
[status,errorMessage,out31, out32]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_3',x1,y1)
status = 1
errorMessage =
out31 = 18
out32 = 100
Example 4 - evalpythonfunction example, calling function with no input arguments and with return values.
[status,errorMessage,out41, out42]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_4')
status = 1
errorMessage =
out41 = 11
out42 = 12
Example 5 - evalpythonfunction example, calling function with no input arguments and with return values.
[status,errorMessage,out51, out52]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_5')
status = 1
errorMessage =
out51 =
{
[1,1] 1
[1,2] 2
[1,3] 3
[1,4] 4
}
out52 = test_call_4