on-internet
← Community

Is there an equivalent to __import__ but for lazy imports?

Stack Overflow ·

Since its earliest days, Python allowed dynamically importing modules via builtins.__import__(): np = __import__('numpy') Although this is now discouraged in favour of importlib.import_module(). Python 3.15 introduced lazy imports, with new lazy import and lazy from syntax: lazy import numpy as np Is there an equivalent to __import__() or import_module() to dynamically and lazily import modules? (I've been here and here, but there's no mention of a dynamic mechanism. And the builtin functions page only mentions __import__().)

Comments

Sign in or sign up to comment and upvote.

No comments yet.