Jim Fulton wrote:

yes indeed, but no "cross" imports between packages that are siblings.

Huh? Why? I'm not at all sure I know what you mean.

the question is what relation between the importer and the imported are OK: if I add such imports in __init__.py, I should only import from packages located in the same folder or in subfolders but not from sibling folders or from parent folders.

with a directory structure like:


- packageA
 |__ packageB

- packageC

in packageA.__init__.py it is OK  to add:

   from root.packageA.somefile import somemodule

to make it possible for external packages to import "somemodule" as:

   from root.packageA import somemodule

it is OK to write in packageA.__init__.py :

   from root.packageA.packageB.somefile import someothermodule

to import it as:

   from root.packageA import someothermodule

but it is not OK to put the same imports in packageC (a sibling), which be some sort or cross import between packages that are not parent / child to one another. This easily leads to circular imports.

so what I mean is : parents import from children to make it possible for external packages to import directly from the parents.


Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to