To work with the tool in Foresight Analytics Platform 10, use the new interface.

PythonInvokeModule

The function wizard for the PythonInvokeModule function looks as follows:

Syntax

PythonInvokeModule(ModuleId, FunctionName, Param,…)

Parameters

ModuleId. Python module identifier in repository.

FunctionName. Executed function name.

Param1, Param2, …, ParamN. Parameters sent to function.

NOTE. To define the parameter, specify either the number or the address of the cell where it is located.

Description

It returns function execution result stored in the Python module.

NOTE. Before using the function, make sure that integration of Foresight Analytics Platform with Python is executed.

Comments

Function can contain several parameters. New formulas are added automatically in the formula wizard after the user puts the cursor into the field with parameter. If extra parameters are added, they should be left empty. If the function contains no parameters, leave the Param field empty.

Keep in mind the following when calling a Python function:

TIP. For details on writing functions in the Python language and on import of modules into the Python library, see Python documentation.

Example

Consider the Python code contained in the Python module with the MOD_PYT identifier:

def calculate(a, b)
    return b%a+a
def check(value)
    if (value>1000):
        return 1
    else
        return 0

The table contains examples of formulas using the PythonInvokeModule function:

Formula Result Description
=PythonInvokeModule("MOD_PYT", "calculate", 4, 40) 4 Calling the calculate function from the Python module in repository with the MOD_PYT identifier. Fixed values are sent as parameters values.
=PythonInvokeModule("MOD_PYT", "check", C3) 1 OR 0 Calling the check function from the Python module in repository with the MOD_PYT identifier. The C3 cell value is sent as parameter value. If the cell value is greater than 1000, then 1 is returned, otherwise - 0.

See also:

Function Wizard │ Functions for Working with Python