The PythonShell plugin offers a CLI interface to a Python shell in OpenCOR’s environment.
$ ./OpenCOR -c PythonShell::help
Commands supported by the PythonShell plugin:
* Display the commands supported by the PythonShell plugin:
help
* Run an interactive Python shell in OpenCOR's environment:
[python] [<option> ...] [-c <command> | -m <module> | <file> | -] [<argument> ...]
where
-c <command> executes a program passed in as a string
-m <module> runs a library module as a script
<file> runs a program read from a script file
- runs a program read from the standard input
$ ./OpenCOR -c PythonShell::python
Python 3.12.2 (main, Apr 4 2024, 21:14:06) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
From the help section above, we can see that the python
command is actually optional, which means that an interactive Python shell can also be launched using:
$ ./OpenCOR -c PythonShell
Python 3.12.2 (main, Apr 4 2024, 21:14:06) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
OpenCOR comes with the pythonshell[.bat]
script, which is an alias to ./OpenCOR -c PythonShell $*
.
So, a third way to launch an interactive Python shell is:
$ ./pythonshell
Python 3.12.2 (main, Apr 4 2024, 21:14:06) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ ./OpenCOR -c PythonShell::python /path/to/my/python/script.py
...
$ ./OpenCOR -c PythonShell /path/to/my/python/script.py
...
$ ./pythonshell /path/to/my/python/script.py
...