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.

Reply via email to