This is how they have made the there package.
There are several way to make a package,they could have lifted sub-modules so all was available under
To give a example.
When build a package have to think of stuff like this.
Can say the last version is more user friendly,if try to figure out a package without looking at doc.
But if they have in doc that most use
If i make package i try to lift sub-modules so all is available under main import,
this make import shorter and easier for user of package to figure out how import work.
There are several way to make a package,they could have lifted sub-modules so all was available under
import botocore
.To give a example.
botocore
is a folder that contain session.py
and a blank __init__.py
.botocore/ |-- __init__.py |-- session.py
# session.py def egg(): print('i am foo')Usage:
λ ptpython >>> import botocore >>> botocore.session Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'botocore' has no attribute 'session' module 'botocore' has no attribute 'session' >>> # Have to use >>> import botocore.session >>> botocore.session.egg() i am fooThere is a fix for this bye modifying the blank import in
__init__.py
.# __init__.py from .session import eggUsage:
λ ptpython >>> import botocore >>> botocore.session.egg() i am foo >>> # Now will also work without session,also we can call egg() function in session.py directly >>> botocore.egg() i am foo
When build a package have to think of stuff like this.
Can say the last version is more user friendly,if try to figure out a package without looking at doc.
But if they have in doc that most use
import botocore.session
,then it's kind of okay.If i make package i try to lift sub-modules so all is available under main import,
this make import shorter and easier for user of package to figure out how import work.