Global python scripting context. More...
Inherits INativeHandle.
Public Member Functions | |
| void | Dispose () |
| IDisposable implementation. | |
| void | AppendSysPath (string path) |
| Adds additional items to the python search path. | |
| PythonObject | GetItem (string itemName) |
| Get the given itemName from this context. Use this to get function and type objects from evaluated code. | |
| PythonObject | Import (string moduleName) |
| Imports the given python moduleName . | |
| PythonObject | Eval (string code, string fileName="<string>") |
| Compiles and evaluates the given python code . | |
Static Public Member Functions | |
| static Context | CreateOrGet () |
| Creates (or retrieves) the process-wide PyScript context for the chosen environment. | |
Properties | |
| Version | InterpreterVersion [get] |
| Gets the Python interpreter version. | |
| IntPtr | Handle [get] |
| Native handle of the Context. | |
| bool | IsDisposed [get] |
| Gets if the native handle has been disposed. | |
Events | |
| NativeHandleEventDelegate | ObjectDisposing |
| Raised when this object is about to be disposed via the IDisposable.Dispose method. | |
Events inherited from INativeHandle | |
| NativeHandleEventDelegate | ObjectDisposing |
| Raised when this object is about to be disposed via the IDisposable.Dispose method. | |
Global python scripting context.
| void AppendSysPath | ( | string | path | ) |
Adds additional items to the python search path.
| path | Path to add. |
| ArgumentNullException | When path is null. |
|
static |
Creates (or retrieves) the process-wide PyScript context for the chosen environment.
The context automatically attaches to the interpreter found on the command line. This may be a system package or pyenv.If a virtual environment is activated, the context will try to attach to this environment, and falls back to the base python if there is an error.
| CvbException | When an error during context creation occurred. |
| PythonObject Eval | ( | string | code, |
| string | fileName = "<string>" ) |
Compiles and evaluates the given python code .
| code | The code to compile and evaluate. |
| fileName | The filename to use for the evaluated code. |
| ArgumentNullException | When code is null. |
| PythonObject GetItem | ( | string | itemName | ) |
Get the given itemName from this context. Use this to get function and type objects from evaluated code.
| itemName | The item to get. |
| ArgumentNullException | When itemName is null. |
| PythonObject Import | ( | string | moduleName | ) |
Imports the given python moduleName .
| moduleName | Name of the module to import. |
| ArgumentNullException |
| NativeHandleEventDelegate ObjectDisposing |
Raised when this object is about to be disposed via the IDisposable.Dispose method.
This event is raised right before this object is disposed. The dispose itself cannot be canceled.