CVB.Net 15.1
Loading...
Searching...
No Matches

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.
 

Detailed Description

Global python scripting context.

Member Function Documentation

◆ AppendSysPath()

void AppendSysPath ( string path)

Adds additional items to the python search path.

Parameters
pathPath to add.
Exceptions
ArgumentNullExceptionWhen path is null.

◆ CreateOrGet()

static Context CreateOrGet ( )
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.

Exceptions
CvbExceptionWhen an error during context creation occurred.

◆ Eval()

PythonObject Eval ( string code,
string fileName = "<string>" )

Compiles and evaluates the given python code .

Parameters
codeThe code to compile and evaluate.
fileNameThe filename to use for the evaluated code.
Returns
A code object - usually not needed. Function and type objects from the evaluated code are available as attributes from the returned object.
Exceptions
ArgumentNullExceptionWhen code is null.

◆ GetItem()

PythonObject GetItem ( string itemName)

Get the given itemName from this context. Use this to get function and type objects from evaluated code.

Parameters
itemNameThe item to get.
Returns
The item.
Exceptions
ArgumentNullExceptionWhen itemName is null.

◆ Import()

PythonObject Import ( string moduleName)

Imports the given python moduleName .

Parameters
moduleNameName of the module to import.
Returns
The module object. Function and type objects from the module code are available as attributes from the returned module object.
Exceptions
ArgumentNullException

Event Documentation

◆ ObjectDisposing

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.