Runtime Types
types.ModuleType — runtime type
Represents module namespaces. ModuleType(name, doc=None) can make a module without importing it; it does not register the object in sys.modules. For import-aware creation use importlib.util.module_from_spec, which initializes import metadata.
Formal Syntax & Structure
python syntaxpython
types.ModuleTypeReturn Value
type
The class object types.ModuleType; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
import typesvalue = types.ModuleType("demo")print(isinstance(value, types.ModuleType))