Python gives us several constructs to group and organize our software. In Section 1, Tighter Integration via Special Methods, we looked at several techniques for using a class definition to combine data structures and behavior together, and create discrete objects defined by structure and behavior. In this chapter, we'll look at modules to encapsulate class and function definitions, as well as shared objects. We'll also look at packages as a design pattern to group related modules together.
Python makes it very easy to create simple modules. Any time we create a Python file, we're creating a module. As the scope of our designs gets larger and more sophisticated, the use of packages becomes more important to maintain a clear organization among the modules. This chapter will suggest patterns for module definition.
Some languages encourage...