I am checking the scikit-learn repository in GitHub to understand how this package is organised. I noticed in all sub-packages (and the main package) __init__.py
file contains a set of import
statements and then all those modules (that have been imported earlier) are assigned to __all__
. (For instance, take a look at https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/metrics/init.py)
I know that by importing a packages (sub-package) all instructions in __init__.py
are executed, and all modules indicated in __all__
list are imported. So, I cannot understand why all the packages that have already been imported are also assigned in __all__
. It seems redundant to me. It would be great if someone can clarify this to me (for example, what would happen if we remove __all__
from __init__.py
file in the example).