A file modu.py in the directory pack/ is imported with the statement import pack.modu.
This statement will look for an
__init__.py file in pack, execute all of its top-level
statements. Then it will look for a file named pack/modu.py and execute all of its top-level
statements. After these operations, any variable, function, or class defined in modu.py
is available in the pack.modu namespace.
A commonly seen issue is to add too much code to
__init__.py files. When the project
complexity grows, there may be sub-packages and sub-sub-packages in a deep directory
structure. In this case, importing a single item from a sub-sub-package will require
__init__.py files met while traversing the tree.
This and other issues led to the idea that using stateless functions is a better programming paradigm.
Another way to say the same thing is to suggest using functions and procedures with as few implicit contexts and side-effects as possible. A function’s implicit context is made up of any of the global variables or items in the persistence layer that are accessed from within the function. Side-effects are the changes that a function makes to its implicit context. If a function saves or deletes data in a global variable or in the persistence layer, it is said to have a side-effect.
However, it may be a good discipline to avoid assigning to a variable more than once, and it helps in grasping the concept of mutable and immutable types.
Depending on the project, your documentation might include some or all of the following components:
docs/ directory inside the project