The Powerful Python Book
-
Your book is absolutely amazing and your ability to articulate clear explanations for advanced concepts is unlike any I have ever seen in any Programming book. Thanks again for writing such a good and thought provoking book.Armando Someillan
-
A must have and must read for every Python developer.Jorge Carlos, Italy
-
I just wanted to let you know what an excellent book this is... It covers so many of the interview questions I'd got wrong previously.Fahad Qazi, London, UK.
-
Powerful Python is already helping me get huge optimization gains.Timothy Dobbins
-
Thanks. Keep up the good work. Your chapter on decorators is the best I have seen on that topic.Leon Tietz, Minnesota
-
A lot of advanced and useful Python features condensed in a single book.Giampaolo Mancini, Italy
-
What have I found good and valuable about the book so far? Everything honestly. The clear explanations, solid code examples have really helped me advance as a Python coder... Thank you! It has really helped me grasp some advanced concepts that I felt were beyond my abilities.Nick S., Colorado, USA
-
Only a couple chapters in so far but already loving the book. Generators are a game changer.Ben Randerson, Aberdeen, UK
-
LOVING Powerful Python so far.Gary Fritz, Colorado, USA
-
Thank you for your book. It is packed with great information, and even better that information is presented in an easy to understand manner.Jon Macpherson
Doing More with Python
Let’s start by defining who this book is not for.
This book is not for people who want just enough Python to get by. Our thesis is that Python is the most important programming language in history, and outsized rewards come to those who master it.
And this book is not for the unambitious. In writing this, I assume you want to build a career you are proud of, doing work with a high positive impact. (And be compensated well for it.)
Further, this book is not for the mentally rigid. The difference between 10X programmers and "normal" coders lies in the distinctions they make, the mental models they leverage, and their ability to perceive what others cannot.
All of which is taught in this book. And it applies equally whether you write code all day every day, or whether coding is one of several skills you use in your work.
Our core tenets are
- Professionalism
- Craftsmanship
- Fun
Professionalism means you can be relied on. You do what you say, and you follow through. Every team you join, you carry your weight, and more. You have standards, those standards are high, and you are an example to all around you. To the point just having you on the team makes people more confident in the project’s success.
Craftsmanship is about excellence in engineering. Writing code you are proud of. That OTHERS are proud of. Hunting down that last farthing of quality, in every corner of the codebase. You take pride in your work, not for the approval of others, but for the approval of yourself.
Fun is about making this journey worthwhile. That we work to make money, yes, and to take care of ourselves and those we love. But that includes creating the most enjoyable memories we can, the best life experiences we can. And if we are going to spend hours today writing code, let’s have a blast so we are excited to do it again tomorrow.
Where this book fits in:
There are many books for people new to Python, or new to programming. But you are past the point where those do you much good. If you’ve been coding in Python for a while already, or Python is your second or third or seventh programming language… you need more.
Reading blog posts can help, as can studying open-source code. And - if you can swing it - working alongside a seasoned Pythonista. But these are not the most convenient ways to learn.
Hence, this book.
Python is richer than you imagine - as a language, as an ecosystem. For many engineering domains, it has grown into a truly outstanding choice for implementing high-quality, robust, maintainable software… everything from one-off scripts to sprawling, mission-critical applications.
This book is designed to help you master all of that: to teach you techniques, patterns, and tools to permanently catapult your skill with everything Python has to offer.
To accomplish that, this book is opinionated and selective. Based on my own experience working in Silicon Valley engineering teams (including two "unicorns"), I focus on certain topics and techniques, deliberately excluding others. Carefully designed to give you the best payoff and value for your reading time.
Many blog posts have been written about different aspects of Python development. Frankly, some of them are not good advice. This book aims to give you excellent advice.
To that end, this book is practical. Based on lessons learned writing real-world software, usually as part of a team of engineers. So factors like maintainability, robustness, and readability are considered more important than anything else. There is a balance between leveraging powerful abstractions, and writing code that is easy to work with by everyone on your team. Every page of this book walks that line.
Throughout, I give much attention to cognitive aspects of software development. How do you write code which you and others can reason about easily, quickly, and accurately? This is one reason variable and function naming is important. But it goes far beyond that syntax level… to intelligently choosing which language features and library resources to use, and which to avoid.
This book is not too large, as measured by number of pages. That’s a feature, not a bug: you already have too much to read. The focus is on what’s most impactfully valuable to you, so that - as much as possible - everything you learn will serve you for years.
Sound good? Let’s begin.
Python Versions
This book aims to be timeless.
Wait, what? For a programming book?
Yes. And it is more possible than you might think.
Here’s why: The structure of quality Python software, and the patterns and strategies that work exceptionally well in the real world, are surprisingly independent of version.
This is truly fortunate; by learning these lasting concepts, you can easily adapt them to all future versions of Python, for years and years to come. It is these slow-changing yet powerful principles we focus on.
The code examples in this book are generally written for Python 3.11 and later. With few exceptions, most will work fine in much older versions of Python. And they will likely not just run, but also be current and useful in far future versions as well.
How To Use This Book
Powerful Python recognizes two levels of learning.
The first is the information level. This is the level of learning where you read something, or I tell you something, and you memorize it. This puts facts, opinions, and other information in your mind, that you can recall later; parrot back to me; and even do some simple reasoning with it.
Which is great.
But there is a much deeper level of learning, called the ability level. The ability to do things you could not do before, when you are writing code.
Both are important…
But the ability level is what you really want.
You see, the information level can be deceptive. It makes you feel like you understand something. But then you go to write code using it, staring at a blank IDE window, and you are stuck scratching your head. "Wait a second. How do I actually use this?"
Know that feeling? Every coder does.
Just reading can only ever teach you at the information level. It is up to you to transform that to ability-level learning. And you do that by putting what you read into practice.
Some ways to do that:
Type out code examples. This is practicing the syntax of the new code patterns. By itself, this does not allow you to fully generalize the feature to all the code you write. But what it does accomplish is teach you the indentation, grammar, and picky details of syntax you did not even realize you missed. It also helps you memorize better, by focusing your attention more deeply. All this makes it easier to put into practice when you ARE writing code.
Which brings us to the next step:
Deliberately write new code using the feature. Look for opportunities to use what just read about. Even inventing a small toy program, just so you can exercise that particular Python feature.
Even better: when you are adding some functionality to an existing program, see if you can directly use that new Python feature you have read about.
This is not always straightforward. Sometimes the code you need to write just does not need that specific language feature, and your list of coding tasks for the day just is not compatible with what you want to "test drive". But the whole point is to stretch your thinking… to practice looking for valuable ways to leverage new tools, in a manner that improves your code quality and development velocity. And some topics - like unit testing - absolutely apply to EVERY program you write.
Bringing us to the next step:
Revisit working code. Have you ever read a book, waited a few years, read it again… and found that it seemed completely different the second time?
Of course, the book did not change. YOU did. So you got different insights, the second time you read it.
Something similar happens when you revisit old code.
Since the program is presumably working, you likely have a good understanding of the code base and the problems it is solving. And when you learn a new Python feature from this book, you can look at your code with fresh eyes… starting to think at higher levels of code organization how this new feature may benefit you. Improving readability, maintainability, robustness, and performance of the function, the module, even the entire code base.
Especially once you start writing automated tests, this becomes a valuable way to learn how use these concepts. When you are still becoming familiar with how to leverage a new feature in realistically complex code, simply attempting to apply it in a well-understood program allows you to quickly learn things about the feature you cannot get from writing a new program.
Get mentoring and guidance. To deeply master Python takes years on your own. Over a decade, in many cases.
To get there faster, Powerful Python Bootcamp is designed to teach you the skills of the top 1% of Python developers, in months or even weeks. Learn more here:
Next Chapter: Scaling With Generators