create_module
Creates and registers a new module instance in sys.modules using a specified base class and attributes. The function dynamically builds the module's fully qualified domain name and populates its namespace with processed attribute values.
def create_module(
name: string,
attrs: dict,
cls_attrs: dict = null,
pkg: module = null,
base: class = LazyModule,
prepare_attr: callable = null
) - > LazyModule
Dynamically creates and registers a new module instance in sys.modules using a specified base class and attribute set.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The full name of the module to be created. |
| attrs | dict | A dictionary of attributes and values to be injected into the module's namespace. |
| cls_attrs | dict = null | Additional attributes to be set on the module's class during instantiation. |
| pkg | module = null | The parent package object used to determine the module's fully qualified domain name. |
| base | class = LazyModule | The base class from which the new module instance will inherit. |
| prepare_attr | callable = null | An optional transformation function applied to each value in the attrs dictionary before assignment. |
Returns
| Type | Description |
|---|---|
LazyModule | The newly created and registered module instance populated with the provided attributes. |