[Python-Dev] New and Improved Import Hooks

Guido van Rossum guido@python.org
Thu, 05 Dec 2002 08:27:29 -0500


> > > > Why don't you care about the backwards incompatibilities?
> > > 
> > > Because it's addressed by using a str subclass.
> > 
> > Which strikes *me* as an ugly hack. :-(
> 
> True, but you can't have your cake and eat it, too: either we implement an
> elaborate scheme of registering handlers for sys.path items, or we keep it
> simple and do our best to avoid breakage.
> 
> Jim Ahlstrom & Paul Moore's patch implement an elaborate scheme which isn't
> exposed to Python, and it adds a fair amount of spaghetti code to an already
> messy part of Python. I'm still a -1 on it.

I know. :-)

> Allowing arbitrary objects on sys.path is simple to explain, document and
> implement, solves the zip import problem and offers a clean high level import
> hook scheme. How much better can it get?

I fear that the requirement that all handlers are str subclasses
raises the bar for writing a handler too much.  But maybe that's not a
problem.  (It's not like writing import hooks is currently a piece of
cake. :-)

So I hereby change my position to -0 on str subclass handlers, which
means you can go ahead.

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