Initializing help system before first use

pyget

Purpose
Get the result of a Python expression as Mosel variable.
Synopsis
procedure pyget(expr:string,var:array|set|list)
function pygetbool(expr:string):boolean
function pygetint(expr:string):integer
function pygetreal(expr:string):real
function pygetstr(expr:string):string
function pygettext(expr:string):text
Arguments
expr 
Python expression to evaluate
var 
Destination Mosel array, set or list
Example
The following example evaluates a Python dictionary expression and writes the result to a Mosel array. It then retrieves a real value from Python:
declarations
  Arr: dynamic array(set of integer) of real
end-declarations

pyexec("import math")
Arr(0) := 0.1; Arr(1) := 1.1          ! Old array data
reset(Arr)                            ! Clear old array data
pyget("{1: math.pi, 2: math.e}", Arr) ! Add new data to array

writeln("Arr: ", Arr)
writeln("pi:  ", pygetreal("math.pi"))
Further information
1. At first, the function interprets the expression as a global variable name and tries to access the variable by getting it from the attributes of the Python __main__ module. If this fails, the expression is evaluated by Python and the result is written to or returned as a Mosel variable. It is a fatal error if the expression evaluation or the type conversion fails.
2. The first version of the pyget routine is additive: it writes the new elements to the existing Mosel array, set or list without clearing previously existing elements. Use reset to manually clear an array, set or list before calling this function.
3. See the I/O Driver python Section for further details about type conversions. Use pycall to call a single function with input arguments or return value.
4. Do not concatenate untrusted strings from the end user into the expr string. See Section Xpress Insight 5 configuration for more information.
Related topics
Module
python3

© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.