I am not getting usage scenarios or design goals of python __init__.py in my projects.
Assume that I have 'model' directory (refers as a package) which I have kept the following files.
1. __init__.py
2. meta.py
3. solrmodel.py
4. mongomodel.py
5. samodel.py
I found two ways of using __init__.py.
I have common definition which needs to be used in solrmodel.py, mongomodel.py, samodel.py. In this case, can I use __init__.py as a base/common definition for all the *model.py classes? This means that I have to import model/__init__.py.
Or, the __init__.py shall have imported definitions of solrmodel.py, mongomodel.py, samodel.py in its own and it allows the easy import of classes or function like this:
file: __init__.py from mongomodel import * from solrmodel import * from samodel import *
(I am aware that import * is not recommended and I just used it as a convention)
I could not decide between above two scenarios. Are there more usage scenarios for __init__.py and can you explain the usage?
References: Python docs says initialization of packages. I could not understand what is there in a package to initialize.