Import and Packaging Modules

importlib.metadata

Reads installed distribution metadata, versions and entry points without requiring import of the target distribution. Distribution names and import package names need not match. EntryPoint.load executes an import, so discovery should be distinguished from loading. The example creates synthetic entry-point metadata without installation.

Formal Syntax & Structure

python syntaxpython
import importlib.metadata

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from importlib.metadata import EntryPointentry = EntryPoint(name="demo", value="math:sqrt", group="tools")print(entry.module, entry.attr)
Python Reference