[Python-Dev] Alternative Approach to Relative Imports
James C. Ahlstrom
jim@interet.com
Mon, 04 Oct 1999 11:16:28 -0400
Greg Stein wrote:
> 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 think my design of leaving a global "Importer" instance variable
in imputil is a bit lame. Each importer is a class instance, but I
don't see a list of importers in imputil.
Suppose impuil kept a list of installed importers
imputil.ImporterList[].
Then to access an importer I have installed, I can write:
for im in imputil.ImporterList:
if isinstance(im, MyImporter):
im.enable(0)
It would not be necessary to dis-install an importer, imputil would
just undertake to keep a list of installed importers, and if someone
wanted to control their installed importers, they would use the list.
I do not feel too strongly about this. Maybe it is a good idea.
What do you think? I can just use my global variable I guess.
Jim Ahlstrom