[Python-Dev] New and Improved Import Hooks

Just van Rossum just@letterror.com
Thu, 5 Dec 2002 16:12:01 +0100


Samuele Pedroni wrote:

> what about __path__'s role in this picture (btw this is not a rhetoric
> question)?

pkg.__path__ is just another sys.path. Whatever rules we make up for sys.path,
they are identical for pkg.__path__. When traversing path, find_module() doesn't
even know whether it's dealing with sys.path or a package's __path__.

The way I see it, the dict that maps path items to handlers also maps __path__
items; all handlers will live there, and there's just one such dict. I think
that a zipimporter would put something like this in __path__

  ["/path/to/archive.zip!packagename"]

So the zip handler will have to do a little more than just checking for a *.zip
extension. I assume you do something like it in Jython, too? (I picked up the
'!' from you I think; it makes it easier/quicker to check for zipness.)

Just