[Python-Dev] PEP 382: Namespace Packages
"Martin v. Löwis"
martin at v.loewis.de
Fri Apr 3 21:55:22 CEST 2009
Chris Withers wrote:
> Martin v. Löwis wrote:
>> I propose the following PEP for inclusion to Python 3.1.
>> Please comment.
> Would this support the following case:
> I have a package called mortar, which defines useful stuff:
> from mortar import content, ...
> I now want to distribute large optional chunks separately, but ideally
> so that the following will will work:
> from mortar.rbd import ...
> from mortar.zodb import ...
> from mortar.wsgi import ...
> Does the PEP support this?
That's the primary purpose of the PEP. You can do this today already
(see the zope package, and the reference to current techniques in the
PEP), but the PEP provides a cleaner way.
In each chunk (which the PEP calls portion), you had a structure like
mortar/rbd.pkg (contains just "*")
As a site effect, you can also do "import mortar", but that would just
give you the (nearly) empty namespace package, whose only significant
contents is the variable __path__.
More information about the Python-Dev