Import and Packaging Modules
importlib
Provides programmatic import operations and the machinery underlying Python imports. import_module accepts a module name and returns the imported module object. Imports normally reuse cached modules in sys.modules and may execute top-level code on first import. Do not import arbitrary user-provided names.
Formal Syntax & Structure
python syntaxpython
import importlibReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import importlibmodule = importlib.import_module("math")print(module.isqrt(81))