sure, they are normal files. Only difference is that they define that the folder is a package.
From python official basic tutorial:
The __init__.py
files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py
can just be an empty file, but it can also execute initialization code for the package or set the __all__
variable, described later.
Note that you usually don't put your code in __init__.py
but instead define it in the packages' modules and import only the names you want to expose in the package namespace.
Here's an example on how to access then, suppose you have this directory structure:
Development/
main.py
setup.py
myprogram/
__init__.py
other.py
The myprogram
folder is considered a package because of __init__.py
so in main.py
you can do:
import myprogram
myprogram.something() # defined in `__init__.py`
import myprogram.other # the submodule other.py inside the package