Chapter 1. Introduction to Robust Python
This book is all about making your Python more manageable. As your codebase grows, you need a specific toolbox of tips, tricks, and strategies to build maintainable code. This book will guide you toward fewer bugs and happier developers. You’ll be taking a hard look at how you write code, and you’ll learn the implications of your decisions. When discussing how code is written, I am reminded of these wise words from C.A.R. Hoare:
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.1
This book is about developing systems the first way. It will be more difficult, yes, but have no fear. I will be your guide on your journey to leveling up your Python game such that, as C.A.R. Hoare says above, there are obviously no deficiencies in your code. Ultimately, this is a book all about writing robust Python.
In this chapter we’re going to cover what robustness means and why you should care about it. We’ll go through how your communication method implies certain benefits and drawbacks, and how best to represent your intentions. “The Zen of Python” states that, when developing code, “There should be one -- and preferably only one -- obvious way to do it.” You’ll learn how to evaluate whether your code is written in an obvious way, and what you can do ...