pyrunfile(filename)
pyrunfile(filename input)
outvars = pyrunfile(filename, outputs)
outvars = pyrunfile(filename, outputs, pyName, pyValue, ...)
| Parameter | Description |
|---|---|
| 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. |
| Parameter | Description |
|---|---|
| outvars | One or more Nelson workspace variable names returned as valid Python types. |
pyrunfile(filenam) function executes Python file.
In contrast to thepyrun function, variables generated in the Python workspace through thepyrunfile function do not persist. This means that subsequent calls topyrunfile 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.
content = "hello Nelson"
print(content)
pyrunfile('pyrunfile_example_1.py')
import sys
print('greetings from:')
for arg in sys.argv[0:]:
print(arg)
pyrunfile('pyrunfile_example_2.py "Hello" "world"')
def minus(a,c):
b = a-c
return b
z = minus(x, y)
pyrunfile('pyrunfile_example_3.py', 'x', 5, 'y', 3)
| Version | Description |
|---|---|
| 1.4.0 | initial version |