8 Modules and packages

Functional programming, which we explored in the previous chapter, is one of the knottiest topics you’ll encounter in the programming world. I’m happy to tell you that this chapter, about Python’s modules, will provide a stark contrast, and will be one of the easiest in this book. Modules are important, but they’re also very straightforward to create and use. So if you find yourself reading this chapter and thinking, “Hey, that’s pretty obvious,” well, that’s just fine.

What are modules in Python, and how do they help us? I’ve already mentioned the acronym DRY, short for “Don’t repeat yourself,” several times in this book. As programmers, we aim to “DRY up” our code by taking identical sections of code and using them ...

Get Python Workout 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.