[Python-Dev] New and Improved Import Hooks
Fredrik Lundh
fredrik@pythonware.com
Wed, 4 Dec 2002 11:33:05 +0100
Jack Jansen wrote:
> > Regarding sys.import_hooks, I see three possibilities:
> >
> > #1
> > for p in sys.path:
> > for hook in sys.import_hooks:
> > hook(p, ...)
> >
> > #2
> > for hook in sys.import_hooks:
> > for p in sys.path:
> > hook(p, ...)
> >
> > #3
> > for hook in sys.import_hooks:
> > # the hook can traversing sys.path if needed.
> > hook(...)
what's wrong with:
#4
for path in sys.path:
if isinstance(path, types.StringTypes):
do_standard_import(...)
else:
path.do_import(...)
after all, everyone knows how the path works, and everyone knows how
to manipulate sys.path inside a Python program.
(for PIL and other plug-in architectures, a "path.get_list_of_modules"
method would also be nice).
</F>