pyrunfile
Run Python file from Nelson.
Syntax
pyrunfile(filename)
pyrunfile(filename input)
outvars = pyrunfile(filename, outputs)
outvars = pyrunfile(filename, outputs, pyName, pyValue, ...)
Input argument
filename - a string scalar, character vector: filename .py to run.
"filename 'input'" - a string scalar, character vector: filename .py to run with input arguments.
pyName, pyValue - Input arguments name and value
outputs - string array: Python variable names.
Output argument
outvars - One or more Nelson workspace variable names returned as valid Python types.
Description
pyrunfile(filenam) function executes Python file.
In contrast to the pyrun function, variables generated in the Python workspace through the pyrunfile function do not persist. This means that subsequent calls to pyrunfile won't be able to access these variables.
The code outvars = pyrunfile(file, outputs, pyName1, pyValue2, ..., pyNameN, pyValueN) executes the code with one or more name-value pair arguments.
Known limitation:
The pyrun and pyrunfile functions lack support for classes containing local variables initialized by other local variables via methods. In such cases, it's advisable to create a module and access it instead.
Examples
pyrunfile_example_1.py
pyrunfile from Nelson
pyrunfile_example_2.py
pyrunfile from Nelson with arguments
pyrunfile_example_3.py
pyrunfile from Nelson with values from Nelson
See also
pyrun, pyenv, Python types supported.
History
1.4.0
initial version
Author
Allan CORNET
Last updated