[Python-Dev] Another approach for the import mechanism
Gustavo Niemeyer
niemeyer@conectiva.com
Thu, 5 Dec 2002 20:44:01 -0200
> 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)
I'm not sure how useful that would be (i.e. I haven't done that by
myself), but that could be handled in the proposed mechanism as well. If
/some/dir/web/http/gopher doesn't exist, that mechanism could check if
http.zip exists, or web.zip exists (or __init__.zip inside those
directories). This also has the advantage that you don't have to enforce
a specific format in your code. If you later discover that tar.bz2 has a
better compression, just go for it. OTOH, I understand that this would
lead to extra tests in comparison with your example.
--
Gustavo Niemeyer
[ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]