Skip to main content

conditional_import

FunctionPrivateSource

module: ModuleType = conditional_import(
name: str
)

Import the module if it exists. Otherwise, return a [`ModulePlaceholder`](./ModulePlaceholder.mdx).

Arguments

Requires

ArgumentTypeRequired
Description
namestrThe name of the module to be imported.

Returns

ArgumentType
Description
moduleModuleTypeIf the module exists, this value is the imported module. Otherwise, it is a ModulePlaceholder.