[Python-Dev] __import__ problems
lists at cheimes.de
Fri Nov 28 21:45:41 CET 2008
Mart Somermaa wrote:
> But it is not. The proposed __import__(name, submodule=True) has
> a compatible interface. All tests pass with
> http://bugs.python.org/file12136/issue4438.diff .
Your approach complicates the interface. Every implementation of Python
and every replacement __import__ would have to implement the additional
argument, too. There is simply no need to make the interface more
complex when an additional, trivial function does the same job.
> As for the imp approach, I've alternatively implemented
> imp.import_module() that imports tail modules in
> (colour diff in http://dpaste.com/hold/94431/).
> IMHO the functionality duplication with __import__ is ugly, but
> if it is desired that __import__ does not change (even in
> backwards-compatible way), so be it.
It's not a duplication of functionality. __import__() implements exactly
the functionality that is required by Python's import system. Anything
else can be implemented on top of it. We simply prefer divide 'n conquer
over mingle 'n mix. :)
More information about the Python-Dev