I have a pretty complex package tree like the following within yet another package
A\
B\
a.py
b.py
c.py
C\
a.py
b.py
c.py
I want to be able to do import A
and access all sub-packages and submodules like A.B.a.foo()
. One way would be to have A/__init__.py
import all of A
's subpackages, but some of the subpackages also import other subpackages (e.g., A.C
uses things from A.B
, leading to an ImportError
. What I'm looking for is a way to do from A import B as A.B
, i.e., import subpackages but still have them be bound to the parent package. Is there a good way to do this?
(I'm not sure what title embodies this question, if someone has a better title then I'll change it.)