importlib (Python 2.7 Backport)

1.0.4 · abandoned · verified Wed Apr 15

This `importlib` package on PyPI is a backport of the `importlib.import_module()` function from Python 2.7. It was created to provide this functionality for Python versions prior to 2.7 and Python 3.0. This project has been archived since November 2017 and is no longer maintained, as the functionality it backported is standard in all currently supported Python versions. It is *not* the standard library `importlib` module fundamental to Python 3's import system.

Warnings

Install

Imports

Quickstart

A basic example demonstrating the use of `importlib.import_module()` from this backport. This package is only relevant for very old Python versions. For Python 3, `importlib` is a built-in standard library module.

import importlib

# This PyPI package primarily provides importlib.import_module
# for older Python 2.x environments where it wasn't built-in.
# For Python 3, 'importlib' is a standard library module.

try:
    # Attempt to dynamically import a module
    math_module = importlib.import_module('math')
    print(f"Successfully imported math module. sqrt(16) = {math_module.sqrt(16)}")
except ImportError as e:
    print(f"Could not import module: {e}")
    print("Note: This 'importlib' PyPI package is a Python 2.7 backport and is obsolete for modern Python 3.x.")

view raw JSON →