Modules

 What is a Module?

  • Modules are collections of specific functionalities designed or implemented to be incorporated into a program.
  • They typically consist of a collection of functions or other entities.
  • Examples of modules include the Python turtle module.

Advantages of modular programming:

  • Allows breaking down large programs into manageable parts (modules).
  • Facilitates separation of programming tasks among individuals or teams.
  • Enables individual development, testing, and integration of modules.
  • Eases program modification by containing code within specific modules.

Module Specification

  • Every module needs to provide a specification, known as its interface, detailing how it is to be used.
  • Programs using a module are referred to as clients of the module.
  • A module's specification should be clear and complete to enable effective utilization.
  • Specifications are often provided using docstrings, which are string literals enclosed in triple quotes.
  • Docstrings describe the purpose and usage of functions or other program elements.
  • Complete specifications may include details such as input range inclusivity and error handling.