Most of the time, the functionality provided by a module is known in advance. The module's source code implements a well-defined set of behavior, and that is all the module does. In some situations, however, you may need a module where the behavior of the module is not completely defined at the time you write it. Other parts of your system can extend the behavior of the module in various ways. Modules that are designed to be extended are called extensible modules.
One of the great things about Python is that it is a dynamic language. You don't need to define and compile all your code before it will run. This makes it easy to create extensible modules using Python.
In this section, we will look at three different ways in which a module can be made extensible: through the use of dynamic imports, by writing plugins, and using hooks.