[Python-Dev] Another approach for the import mechanism

Skip Montanaro skip@pobox.com
Thu, 5 Dec 2002 16:24:55 -0600


    Skip> Remember, a zip file looks like a directory because of its
    Skip> embedded structure.  If you had httplib.zip it would have to
    Skip> contain at least one .py or .so (or .pyd or ...) file.  I think
    Skip> you would insert /some/dir/httplib.zip into sys.path.

Just rereading my own note, I realize you might have components after the
zip file name.  Suppose you had web.zip which contained directories http,
gopher, ftp, and nntp, each of which was itself a package (had a __init__.py
file).  You might modify sys.path like so:

    newdirs = [os.path.join("/some/dir/web.zip", x)
                  for x in "http gopher ftp nttp".split()]
    sys.path.extend(newdirs)

Skip