Info Node: (python2.1-tut.info)Intra-package References
(python2.1-tut.info)Intra-package References
Intra-package References
------------------------
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. Thus, the
surround module can simply use `import echo' or `from echo import
echofilter'. If the imported module is not found in the current
package (the package of which the current module is a submodule), the
`import' statement looks for a top-level module with the given name.
When packages are structured into subpackages (as with the `Sound'
package in the example), there's no shortcut to refer to submodules of
sibling packages - the full name of the subpackage must be used. For
example, if the module `Sound.Filters.vocoder' needs to use the `echo'
module in the `Sound.Effects' package, it can use `from Sound.Effects
import echo'.