Blame | Last modification | View Log | Download
18.3.2 Basic use of the mathproj package>>> import mathprojHello from mathproj init>>> mathproj.version1.0318.3.3 Loading subpackages and submodules>>> import mathprojHello from mathproj init>>> mathproj.comp.numeric.n1Traceback (most recent call last):File "<stdin>", line 1, in <module>AttributeError: module 'mathproj' has no attribute 'comp'>>> import mathproj.comp.numeric.n1Hello from mathproj.comp initHello from numeric init>>> mathproj.comp.numeric.n1.g()version is 1.03Called function h in module n2>>> mathproj.comp<module 'mathproj.comp' from 'mathproj/comp/__init__.py'>>>> mathproj.comp.numeric<module 'mathproj.comp.numeric' from 'mathproj/comp/numeric/__init__.py'>18.3.4 import statements within packagesfrom mathproj import versionfrom mathproj.comp import c1from mathproj.comp.numeric.n2 import hdef g():print("version is", version)print(h())from .n2 import hfrom mathproj import versionfrom mathproj.comp import c1from mathproj.comp.numeric.n2 import hfrom ... import versionfrom .. import c1from . n2 import h18.4 The __all__ attribute>>> from mathproj import *Hello from mathproj initHello from mathproj.comp init>>> comp<module 'mathproj.comp' from 'mathproj/comp/__init__.py'>>>> c1Traceback (most recent call last):File "<stdin>", line 1, in <module>NameError: name 'c1' is not defined>>> from mathproj.comp import c1>>> c1<module 'mathproj.comp.c1' from 'mathproj/comp/c1.py'>