The Effective Software Development Series
There is a series of books being released by InformIT called the Effective Software Development Series where they write books for many languages (so far 8, and counting) as well as some broader topics (Code Quality: The Open Source Perspective and Code Reading: The Open Source Perspective). For the most part, they all have a similar format of a number of items that let you write better programs in a certain language. In Effective Python’s case, it’s “59 Specific Ways to Write Better Python”.
These books seem to draw inspiration for their format from the old Effective C++ and Effective Java books. I read Effective Java a few years ago, and that’s what fueled my doubling down on learning Java. These books somehow turn a minor interest in a language into a deep-felt love of them (in my experience anyway), and turn distaste into an appreciation of the challenges the language has had to deal with.
I was already well in love with Python, and I had actually already read up on many of the tips that were provided in this book, but there was still plenty to learn about why some of those things were true. That’s the real beauty of these books; they don’t just give you tips on what to do, but they really divulge on the why. They usually look at commonly used alternatives that are flawed or don’t work as well before really explaining the tip.
Here is a list of some of my favorite tips in the book:
- Avoid using start, end, and stride in a Single Slice – Item 6
- Prefer Exceptions to Returning None – Item 14
- Consider Generators Instead of Returning Lists – Item 16
- Enforce Clarity with Keyword-Only Arguments – Item 21
- Use Multiple Inheritance Only for Mix-in Utility Classes – Item 26
- Know How to Break Circular Dependencies – Item 52
And that’s just a tiny sampling!
Seriously, y’all, if you’re relatively new to a language, I highly recommend checking to see if there’s an Effective __ book for it. I love ’em.