[Distutils] modules in different folders but under same namespace

Floris Bruynooghe floris.bruynooghe at gmail.com
Thu Feb 4 18:37:45 CET 2010

On Thu, Feb 04, 2010 at 05:53:16PM +0100, Riccardo-Maria BIANCHI wrote:
> Now I can import them as:
> package.src.mod1
> package.share.mod2
> How can I use Distutils to be able to import both of them under the
> same "package" namespace as:
> import package.mod1
> import package.mod2

In package/__init__.py:

import src.mod1 as mod1
import share.mod2 as mod2

And then you can use just one "import package" statement.  If you want
src and share to be separately installable then it gets more
complicated (you'd need namespace packages etc), but why complicated
when simple works?


Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org

More information about the Distutils-SIG mailing list