To clarify "inter-package dependencies". I'm assuming that you mean a
setup like the following:
APP/
modules/
modulea/
...some python files...
moduleb/
...some more python files...
If you want to use something from moduleb inside modulea (assuming
that both have the __init__.py in their directories),
from ..moduleb import * --> or import classA, etc
I use it in several parts of an app that I have, it works just fine.
On Apr 6, 9:39 am, pierreth <[email protected]> wrote:
> Here are my conclusion on using the "modules" directory.
>
> What is working:
>
> - Using local_import avoid collisions of modules or packages that may
> have the same names in other applications.
> - Explicit and implicit relative imports are working well for modules
> located in the "modules" directory.
>
> What is not working:
>
> - Absolute imports does not work because "modules" is not in the
> Python path.
>
> What this mean in practice:
>
> - Modules located in "modules" can import each other if there are not
> located in a package. This is implicit relative import.
> - local_import is working well with both modules and packages.
> - Modules located in "modules", regardless of if they are or not
> located in a package, can only import other modules located both in a
> package and in "modules" using explicit relative imports. Absolute
> imports only work for modules and packages located in the Python path.
>
> So if you drop both a module "a" depending on module "b" in "modules",
> they will probably work very well. But if you drop both a package "a"
> depending on package "b" (or a module "b"), it will probably not work.
> Using relative imports in this case is not the norm. Inter packages
> dependencies will not work in "modules". Is this a bug?
>
> See:http://docs.python.org/tutorial/modules.html#packages
>
> I suggest to add this message to the web2py book.