Python comes with a very nice feature that enables each module to self-test. Making use of this feature is a great way of making sure that changes to our code do not break existing code and, additionally, the
__main__ self-testing section can serve as documentation for how each module works.
After a few months or years, we sometimes forget what our code is doing, so having an explanation written in the code itself is indeed a great help.
It is a good idea to always add a self-testing section to every Python module, when possible. It is sometimes not possible, but, in most modules, it is possible to do so.
We will extend the previous recipe, so, in order to understand what ...