Technical requirements

The code files for this chapter are available at https://git.io/fj2US.

One common approach is a single module. The overall organization can be imagined this way:

module.py
┣━━ class A:
┃ ┗━━ def method(self): ...
┣━━ class B:
┃ ┗━━ def method(self): ...
┗━━ def function(): ...

This example shows a single module with a number of classes and functions. We'll turn to module design in the Designing a module section, later in this chapter.

A more complex approach is a package of modules, which can be imagined as follows:

package
┣━━ __init__.py
┣━━ module1.py
┃ ┣━━ class A:
┃ ┃ ┗━━ def method(self): ...
┃ ┗━━ def function(): ...
┗━━ module2.py
┗━━ ...

This example shows a single package with two modules. Each module contains classes and functions. We'll look at package design in the Designing a package section later in this chapter.

We're going to avoid the more complex problem of distributing Python code. There are a number of techniques to create a source distribution for a Python project. The various distribution technologies are outside the scope of this book. The Software Packaging and Distribution section of the Python Standard Library addresses some of the physical file packaging issues. The Distributing Python Modules document provides information on creating a code distribution.

In this chapter, we will cover the following topics:

  • Designing a module
  • Whole modules versus module items
  • Designing a package
  • Designing a main script and the main module
  • Designing long-running applications
  • Organizing code into src, scripts, tests, and docs
  • Installing Python modules
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset