Skip to content

Conversation

bhearsum
Copy link
Contributor

import_module is newer, and provides a couple of advantages over a bare __import__:

The import_module() function acts as a simplifying wrapper around importlib.import(). This means all semantics of the function are derived from importlib.import(). The most important difference between these two functions is that import_module() returns the specified package or module (e.g. pkg.mod), while import() returns the top-level package or module (e.g. pkg).

It's unclear if this will actually fix any problems in the real world, but there's no recent to use __import__ at this point AFAICT.

@bhearsum bhearsum requested a review from a team as a code owner August 14, 2025 15:43
`import_module` is newer, and provides a couple of advantages over a bare `__import__`:
> The import_module() function acts as a simplifying wrapper around importlib.__import__(). This means all semantics of the function are derived from importlib.__import__(). The most important difference between these two functions is that import_module() returns the specified package or module (e.g. pkg.mod), while __import__() returns the top-level package or module (e.g. pkg).

It's unclear if this will actually fix any problems in the real world, but there's no recent to use `__import__` at this point AFAICT.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants