[Python-Dev] New and Improved Import Hooks

Guido van Rossum guido@python.org
Mon, 09 Dec 2002 12:39:07 -0500


> Guido van Rossum wrote:
> 
> > The problem with trying to load x.y right away is that then you can't
> > distinguish between "x.y doesn't exist" (and then you go to step 2)
> > as opposed to "x.y exists, but it tries to import something else that
> > raised ImportError" (and then you should simply propagate the
> > exception).

[His brother replied]
> Also not true: a function that finds *and* loads a module can return
> None for "module not found", a new module object upon succes, and
> propagate an error if one did occur during import. I'm tempted to
> make my new import hook scheme work that way: it avoids a few hoops
> I have to go through with import.c, as right now I'm quite limited
> what zipimporter.find_module() can communicate to
> zipimporter.load_module(). (It would also make it even closer to
> iu.py ;-)

OK, sounds like it can work, if b/w compat issues are taken care of.

--Guido van Rossum (home page: http://www.python.org/~guido/)