Evaluates a Python expression and assigns its value to a variable.

 

   

Syntax
 

[C#]
void SetAfterEval(string name, string expr, PythonScope evalScope, in options)

 

Throws Exceptions ObjectDisposedException: Thrown when this PythonScope has been disposed of.
Throws Exceptions ArgumentNullException: Thrown when name is null.
Throws Exceptions ArgumentException: Thrown when name is not a valid Python identifier.

 

   

Params
 
Name Description
name The name of the variable.
expr A Python expression.
evalScope A scope where is evaluated. The current PythonScope is used if it is null.
options Options for running Python code.

 

   

Notes
 

Evaluates a Python expression and assigns its value to a variable.

 

   

Example
 

You can re-use a complex object using code of the following form.

 

var options = new PythonOptions(); options.Initialize(PythonEnvironment.Current, null); using var rt = PythonEnvironment.Current.GetRuntime(); using var scope = rt.CreateScope(); rt.StdOutWriter = Console.Out; rt.StdErrWriter = Console.Error; rt.AutoInitializeRuntime(scope, null); scope.Exec(   "from docling.datamodel.accelerator_options import AcceleratorDevice, AcceleratorOptions\n" +   "from docling.datamodel.base_models import InputFormat\n" +   "from docling.datamodel.pipeline_options import ThreadedPdfPipelineOptions\n" +   "from docling.document_converter import PdfFormatOption\n" ); scope.SetAfterEval("myFormatOptions", "{InputFormat.PDF: PdfFormatOption(pipeline_options=ThreadedPdfPipelineOptions(do_ocr=False, accelerator_options=AcceleratorOptions(device=AcceleratorDevice.CPU)))}"); var op = new AccessibilityOperationAI(); op.ConversionOptions = "myFormatOptions"; // ... do work