Package Organization (was Re: [Zope3-dev] Voting on Schema design)
Fred L. Drake, Jr.
fdrake@acm.org
Mon, 15 Jul 2002 14:22:05 -0400
Barry A. Warsaw writes:
> Interesting. So Zope/__init__.py should contain something like:
>
> -------------------- snip snip --------------------
> import os
> import sys
>
> for dir in sys.path:
> fullpath = os.path.join(dir, 'Zope')
> initfile = os.path.join(fullpath, '__init__.py')
> if os.path.exists(initfile):
> # Should the other package be searched first or later?
> __path__.append(fullpath)
> -------------------- snip snip --------------------
Actually, this would ensure the directory containing this would be
searched twice before other matching directories were searched, since
it will add itself again as the first matching directory. (__path__
is initialized to contain the directory containing the package as
determined by the standard importer.)
> One problem is the inability to answer the question in the comment,
> since either answer may be correct depending on the circumstances.
Yes, that's a real problem.
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation