Summary

In this chapter, we looked at the concept of a reusable module or package. We saw how reusable packages and modules can be used to share code with other people. We learned that a reusable module or package needs to function as a standalone unit, should ideally use relative imports, and should note any external dependencies it may have. Ideally, a reusable package or module will also solve a general problem rather than a specific one, follow standard Python coding conventions, and have good documentation. We then looked at some examples of good reusable modules, before writing one of our own.

In the next chapter, we will look at some of the more advanced aspects of working with modules and packages in Python.

Get Modular Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.