[Python-Dev] Re: New and Improved Import Hooks

Chermside, Michael mchermside@ingdirect.com
Tue, 3 Dec 2002 16:11:35 -0500


> > 1. Your import hooks seem to act at a level "above" sys.path,
> >    in the sense that the normal sys.path search becomes just
> >    another hook. With that in mind, I don't see a way for a user
> >    to add a zipfile in the *middle* of sys.path.
>=20
> True. There would be ways around that, but it's currently not easy. I =
don't feel
> this is a particularly important feature, though.

Hmm... Not sure I agree. I think this is one area where we'd
be wise to follow Java's example. Normally I think it's wise
for Python to do its own design instead of imitating the errors
of other languages, but this is the exception.

  (1) Java (AFAIK) originated the idea of mixing .zip files as
      part of the path.
  (2) Their approach makes sense (in my mind, it would make sense
      to say "zip archives appear in path and are treated as if they=20
      were subdirectories", and it would ALSO make sense to say
      "the list of zip archives is separate from the path". But some
      mix like "zip archives appear in the path, but we treat them
      as if they were at the end even though they aren't" doesn't
      make sense).
  (3) It makes sense for Jython (for obvious reasons!).

Because of (1), along with the popularity of java, putting .zip's
on the path will seem "natural and familiar" to lots of Python
programmers. Because of (2) it isn't a BAD idea. And (3) is just
another good motivation... let's keep c-python and jython as
similar as possible!

I sympathize about this being "not currently easy", but...

-- Michael Chermside

PS: I like the import-hooks idea, and I think the zip importer is
an excellent test case to really see how well the concept plays
in practice.