Self-wrote-python-packaging (for testing)
OUR PACKAGE TREE HIERARCHY,
RamPyPackage FOLDER |
---|
|
|--subdir1 FOLDER
| |---- subsubdir1 FOLDER
| | |------ bottom_of_subsubdir1.py
| | |______ __init__.py
| |
| |---- intermediate_from_subdir1.py
| |
| |---- intermediate_2_from_subdir1.py
| |
| |____ __init__.py
|
|--subdir2 FOLDER
| |---- bottom_of_subdir2.py
| |---- test.py
| |____ __init__.py
|
|__ __init__.py
** hey_stay_here_and_try_all_comb **
Hints :-
-
all declaration is not necessary.
-
init.py should be there to import all necessary modules when installing the package.
-
for importing the sub directories (not files),
from . import subdir1
is enough -
for importing the sub file(module),
from .sub_module import sub_module
is better, if the sub_module is a class on the sub module file. -
no need to start the importing of the sub-modules in our current script by starting from top package name.
from Top_package.sub1.sub12 import sub12
This is not necessary to include Top_package at the front.
Just the below line is enough.
from sub1.sub12 import sub12