Written August 2025
PYFUNC() provides a means to call an external function written in Python version 3.
PYFUNC (module, funcname {, arg1, ... argn}) ! (numeric return value)
PYFUNC$ (module, funcname{, arg1 ... argn}) ! (string return value)
where:
module (String) [in]
filespec (native format) of the module containing the function; (default extension py)
funcname (String) [in]
name of the function to call
arg1 ... argn (any scalar type) [in]
zero or more arguments to the function
PYFUNC uses the Python C interface API to initialize the Python environment. If necessary, certain Python environment variables can be set via the file %MIAME%/pyconfig.ini, formatted as follows:
[Python]
;Base directory for Python installation (executable)
HOME=C:\Program Files (x86)\Python312-32
;PLATLIBDIR=
The pyconfig.ini file can be eliminated if Python is set up to run from the command or shell prompt without explicit settings.
Unlike other A-Shell function interfaces, the parameters here are all read-only, so if the function is to return anything to caller, it must be done through the return value of the function, either a scalar or an auto-extend array. Examples:
city$ = pyfunc$("./geo.py", "capital_of", "California")
median = pyfunc(".math.py", "median", 5, 23, 15, 100, 44, 11)
dimx ary(0), b, 2, auto_extend
...
ary() = pyfunc("./mymod.py", "myfunc", 10, 20, 30)
Warning: this interface is still in the experimental stage. We're not yet sure if there's really any application for it, and there are a number of complexities that will need to be sorted out. Developers are advised to provide feedback to us before investing too much effort into it.