I'm creating a big variety of programs and because of this I need lots of different packages and modules. Some of them I've written myself and some are downloaded.
The downloaded modules all have __init__.py
files in their main directorys and somewhere random in the sub-directorys. Here is an example:
/theexamplemodule
|-__init__.py #first
|-file1.py
|-file2.py
|-folder1
| |-__init__.py #second
| |-file3.py
|-folder2
| |-data.txt
| |-file4.py
I've searched around on stackverflow and I found this 'What is __init__.py for?' answer why the first one is there, it sets the directorys as modules or some thing like that...
But why is this declaration nessecary and what is the sence of the others?
My own modules are build similar to this but without the __init__.py
files. I don't get the advantages of the __init__.py
files. What are those advantages?