Table of Contents

Class PythonHelper

Namespace
Bonsai.ML.Python
Assembly
Bonsai.ML.Python.dll

Provides a set of extension methods for working with Python.Runtime.PyObject instances.

public static class PythonHelper
Inheritance
PythonHelper
Inherited Members

Methods

ConvertPythonObjectToCSharp(PyObject)

Converts the specified Python object to a C# object.

public static object ConvertPythonObjectToCSharp(PyObject pyObject)

Parameters

pyObject PyObject

The Python object to convert.

Returns

object

The C# object representation of the Python object.

GetArrayAttr(PyObject, string)

Gets the value of the specified array attribute from the Python object.

public static object GetArrayAttr(this PyObject pyObject, string attributeName)

Parameters

pyObject PyObject

The Python object.

attributeName string

The name of the attribute to retrieve.

Returns

object

The array value of the specified attribute.

GetAttr<T>(PyObject, string)

Gets the value of the specified attribute from the Python object.

public static T GetAttr<T>(this PyObject pyObject, string attributeName)

Parameters

pyObject PyObject

The Python object.

attributeName string

The name of the attribute to retrieve.

Returns

T

The value of the specified attribute.

Type Parameters

T

The type of the attribute to retrieve.