[Python-Dev] Another approach for the import mechanism

Gustavo Niemeyer niemeyer@conectiva.com
Thu, 5 Dec 2002 19:26:16 -0200


I propose a different approach to the importer hook mechanism:

- An importer register itself with sys.register_importer(), as suggested
  by MAL.

- No .zip/.tar/.whatever files are ever included in sys.path

- Alternative importers are only considered when the default importer
  mechanism fails (each entry in the path at a time, so that
  precedence is preserved).

- Alternative importers, when activated, would be given the module name
  being imported, and would look for entries in the "current" iterated
  path by themselves.

- A zip importer would, for example, look if the current iterated path
  have a file named "__init__.zip".

- The same importer could also be able to look for a file named
  "mypackage.zip", if "import mypackage.foo" is tried.

What's your opinion about that?

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]