Utils
imp utils
Types
Utils
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Raises
else: warn(msg)
getmodule
getmodule (name:str, lazy:Optional[bool]=False, alias:Optional[str]=None, inject:Optional[bool]=True, inject_both:Optional[bool]=False)
Get a module by name, importing it if necessary.
Type | Default | Details | |
---|---|---|---|
name | str | Name of the module to get. | |
lazy | Optional | False | If True, use lazy import; if False, use regular import. |
alias | Optional | None | Alias to use for the module. |
inject | Optional | True | If True, inject the module into sys.modules. |
inject_both | Optional | False | If True, inject the module into sys.modules with both its original name and alias. |
Returns | module | The requested module. |
module_from_str
module_from_str (name:str, lazy:bool=False, alias:Optional[str]=None, inject:Optional[bool]=True, inject_both:Optional[bool]=False)
Import a module from a given string name.
Type | Default | Details | |
---|---|---|---|
name | str | Name of the module to import. | |
lazy | bool | False | If True, use lazy import; if False, use regular import. |
alias | Optional | None | Alias to use for the module. |
inject | Optional | True | If True, inject the module into sys.modules. |
inject_both | Optional | False | If True, inject the module into sys.modules with both its original name and alias. |
Returns | module | The imported module. |
loader_from_spec
loader_from_spec (spec:_frozen_importlib.ModuleSpec, lazy:bool=False)
Get a loader from a given module specification.
Type | Default | Details | |
---|---|---|---|
spec | ModuleSpec | Module specification from which to get the loader. | |
lazy | bool | False | If True, return a LazyLoader; if False, return the original loader. |
Returns | Loader | Loader for the module. |
is_mod_avail
is_mod_avail (name:str)
Check if a given module name is available for import.
Type | Details | |
---|---|---|
name | str | Name of the module to be checked. |
Returns | bool | True if the module is available for import, False otherwise. |
is_mod_or_var
is_mod_or_var (name:str)
Check if a given name exists either as a module or a variable.
Type | Details | |
---|---|---|
name | str | Name to be checked. |
Returns | bool | True if the name exists either as a module or a variable, False otherwise. |
is_var_imp
is_var_imp (name:str)
Check if a given variable name exists in the global namespace.
Type | Details | |
---|---|---|
name | str | Name of the variable to be checked. |
Returns | bool | True if the variable exists in the global namespace, False otherwise. |
is_mod_imp
is_mod_imp (name:str)
Check if a given module name is in the system module list.
Type | Details | |
---|---|---|
name | str | Name of the module to be checked. |
Returns | bool | True if the module is in the system module list, False otherwise. |
is_mod
is_mod (module:Any)
Check if a given object is a module.
Type | Details | |
---|---|---|
module | Any | Object to be checked. |
Returns | bool | True if the object is a module, False otherwise. |
modjoin
modjoin (*parts:str)
Join module name parts into a valid module path.
Type | Details | |
---|---|---|
parts | str | |
Returns | str | Valid module path. |