├─mathproj
│ │ __init__.py
│ │
│ └─comp
│ │ c1.py
│ │ __init__.py
│ │
│ └─numeric
│ n1.py
│ n2.py
│ n3.py
│ __init__.py
Let's see each file in sequence.
/mathproj/__init__.py
print("Hello from mathproj init") __all__ = ['comp'] version = 1.03/mathproj/comp/__init__.py
__all__ = ['c1'] print("Hello from mathproj.comp init")/math/comp/c1.py
x = 1.00/math/numeric/__init.__.py
print("Hello from numeric init")/math/numeric/n1.py
from mathproj import version from mathproj.comp import c1 from mathproj.comp.numeric.n2 import h def g(): print("version is", version) print(h())/math/numeric/n2.py
def h(): return "Called function h in module n2"
''' file: n3.py description: this is a transformed of the n2.py which shows you can do differently with the modules. ''' from ... import version from .. import c1 from . n2 import h # from .n2 import h # this is the same as the line above def g(): print("version is", version) print(h())