get_instance_of

lsst.utils.introspection.get_instance_of(typeOrName: Type | str, *args: Any, **kwargs: Any) Any

Given the type name or a type, instantiate an object of that type.

If a type name is given, an attempt will be made to import the type.

Parameters:
typeOrNamestr or Python class

A string describing the Python class to load or a Python type.

argstuple

Positional arguments to use pass to the object constructor.

**kwargs

Keyword arguments to pass to object constructor.

Returns:
instanceobject

Instance of the requested type, instantiated with the provided parameters.

Raises:
TypeError

Raised if a module is imported rather than a type.