[Python-Dev] Re: [Zope3-dev] Zip import and sys.path manipulation (was Re: directory hierarchy proposal)

Paul Moore lists@morpheus.demon.co.uk
Mon, 16 Dec 2002 22:54:44 +0000


Guido van Rossum <guido@python.org> writes:

>> Playing tricks with the contents of pkg.__path__ apparently has its
>> uses,
>
> It's the *defined* API for adding to the set of locations from which
> submodules and subpackages of a package are to be loaded.  You can't
> just call that "playing tricks."

This is entirely true. I think the key issue for import hooks is
whether application code is entitled to make assumptions about what
the system puts onto pkg.__path__ before __init__.py gets control.

But the writer of __init__.py knows how the package is being packaged,
and hence what import hook is responsible for setting up __path__. So
it can be coded appropriately.

The mistake here is in assuming that arbitrary code can be
transparently zipped (or stored in another way, using an import hook)
and still work. Some (most) code can, but not all.

> Of course.  If you freeze code, you have to make sure that it will be
> able to find its data files in some other way.  But not all code has
> to be freezable.

This agrees with what I just said (with "freeze" replaced by "zip" or
whatever).

Paul
-- 
This signature intentionally left blank