utilities.load_class

utilities.load_class(fully_qualified_name: str) type[source]

Dynamically load a Python class from its fully qualified name.

This function loads a class by parsing the fully qualified name string, importing the module, and retrieving the class object from the module.

Parameters:

fully_qualified_name (str) – The fully qualified name of the class to load in the format module.ClassName.

Returns:

The loaded class object.

Return type:

type

Raises:

OXception – If the class cannot be loaded due to import errors or missing class names.

Examples

Load classes dynamically:

# Load a framework class
obj_class = load_class("base.OXObject.OXObject")
instance = obj_class()

# Roundtrip demonstration
from base.OXObject import OXObject
name = get_fully_qualified_name(OXObject)
loaded_class = load_class(name)
assert loaded_class is OXObject

See also

get_fully_qualified_name(): Generate class names for use with this function.