[Python-Dev] Alternative Approach to Relative Imports

Greg Stein gstein@lyra.org
Mon, 4 Oct 1999 02:51:53 -0700 (PDT)


On Wed, 29 Sep 1999, James C. Ahlstrom wrote:
> "M.-A. Lemburg" wrote:
> > I know, but there still is no way to query what kind of hooks
> > are already loaded and what is worse, you cannot unload or reorder
> > them.
> 
> I think this is a valid point.  I am interested in hooks to read
> modules from a file archive.  If you are a developer, it is
> necessary to turn this hook OFF, so that you can revert to the
> usual directory tree where your current source is.
> 
> I am solving this by leaving a global variable "Importer" in
> sitecustomize, and calling sitecustomize.Importer.enable(0).
> This works, but it might be useful if imputil could de-install
> a hook as well as install it.

It was a design point to not provide this functionality. It is pretty
difficult to unhook the importers from the chain. I specifically said,
"well... when you alter the import behavior, then it will stay that way."

I figured this was entirely safe since an Importer could have an
enable/disable flag like you implemented, or my (theoretical) Import
Manager could pull an Importer out of its list that it was managing.

I'm not sure that we want an Import Manager to always be installed in the
hooks, but it could be a good idea to have a standard manager in the
library somewhere (which Importers could state a dependency upon its
installation).

Cheers,
-g

--
Greg Stein, http://www.lyra.org/