[Python-Dev] New and Improved Import Hooks

M.-A. Lemburg mal@lemburg.com
Thu, 05 Dec 2002 12:15:36 +0100


Fredrik Lundh wrote:
>>Here's a sketch:
>>
>>1. User programs register import hooks based on REs which are
>>    used to match the entries in sys.path, e.g. ".*\.zip" for
>>    ZIP importers (caching could help in improving the mapping
>>    performance).
> 
> a solution that won't let you wrap up the standard library isn't much
> of a solution (portions of both RE engines are written in Python)

As I said, this was a sketch. Things like zip imports should
be built-in to avoid bootstrapping problems like the one
you mention.

> I think this is overkill.  let's keep it simple and grokable.

Hmm, that's what I was after :-) Nothing complicated like importers
which pretend to be strings or one of the current white magic
solutions in use today.

You should basically be able to say

	sys.path.append('/usr/local/lib/python2.3/std.zip')

and have the Python std lib at your fingertips. From a user
POV I don't want to bother about how Python manages to get
at the stuff inside the ZIP archive.

Also note that any solution using special objects in sys.path
is not compatible with the PYTHONPATH environment variable
(or registry setting). The above approach is...

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/