I have package p
that has modules a
and b
. a
relies on b
:
b.py
contents:
After rereading the Python import documentation, the correct answer to my original problem is:
To ensure that b
imports a
from its own package its just enough to write the following in the b
:
import a
Here is the quote from the docs:
The submodules often need to refer to each other. For example, the surround module might use the echo module. In fact, such references are so common that the import statement first looks in the containing package before looking in the standard module search path.
Note: As J.F. Sebastian suggest in the comment below, use of implicit imports is not advised, and they are, in fact, gone in Python 3.