Historical and Removed Modules

imp

Removed from the standard library in Python 3.12; historical example targets Python 3.11. Exposed older import machinery, including finding modules and creating module objects. Use importlib and importlib.util for modern module specifications and imports. Importing or executing arbitrary module code is not a sandbox.

Formal Syntax & Structure

python syntaxpython
import imp  # Historical only: removed in Python 3.12

Return Value

module (historical)

Historical module namespace, not a supported standard-library import on the Python 3.13 baseline.

Working Example

Example Snippetpython
# Historical example: Python 3.11; not executed.import impprint(imp.new_module("demo").__name__)
Python Reference