Pydon’ts – Write elegant Python code: Free Book Review
The book consists of 200 actionable Python insights with a detailed explanation of how to write elegant, compelling, and expressive code.
Image by author
When I started learning Python, my entire focus was on learning data science instead of the software engineering side of the programming language. I missed a lot of core concepts of the language that could have helped me write clean and reproducible code.
I am not alone in this journey. Some of my colleagues and other data scientists have similar issues where they just want to solve a data science problem with poorly written code. The code is unreadable, chunky, and harder to reproduce and maintain. Instead of using an object-oriented approach, most data professionals use functional programming, which is adequate for experimentation but not for production. Some of us don’t even know what chaining comparison operators are, walrus operator, repr, sequence indexing, slicing, and pattern matching.
These bad coding practices cause delays and conflicts as it is hard to understand and optimize existing code. So, I started learning Python for software engineers. I took multiple courses and read books on mastering Python. These resources have helped me understand object-oriented programing, coding style, clean and reproducible code, refactoring, and test-driven development. This was not it. I wanted to learn more. I wanted to learn how to write elegant, compelling, and expressive code. This is where I found a free book called Pydon'ts, which helped me understand what I was missing in my coding practice.
In this short book review, I have mentioned the things that I love about this book and how you can use this book to impress your colleagues and get better at writing elegant code.
Pydon'ts is totally free and has 330+ pages of pure knowledge. This book is for all professionals and enthusiasts who want to get better at writing elegant and production-ready code. Especially data scientists who are still writing code that is only understood by them. The book consists of 20 chapters that will teach you about Python built-ins and their various usage patterns. Each chapter contains an introduction, various usage patterns of a single function, coding examples, conclusions, and references. In short, every chapter is like a short blog explaining each concept in detail with a real project example.
The author of the book Rodrigo has been writing Python for seven and half years, and he has a blog Mathspp Blog, that covers interesting concepts of mathematics and programming language. He is highly respected in the Python community, and his vision is to teach people free of cost about the best practices of the Python language. Python is a rich language, and every chapter in this book explores a single feature in detail, accompanied by code examples covering all the angles.
Python features that the book covers in details:
- Code style matters
- Naming matters
- Chaining comparison operators
- Assignment expressions and the walrus operator :=
- Truthy, Falsy, and bool
- Deep unpacking
- Unpacking with starred assignments
- EAFP and LBYL coding styles
- Zip up
- str and repr
- Structural pattern matching tutorial
- Structural pattern matching anti-patterns
- Watch out for recursion
- Sequence indexing
- Idiomatic sequence slicing
- Mastering sequence slicing
- Inner workings of sequence slicing
- The power of reduce
- Usages of underscore
- name dunder attribute
- Bite-sized refactoring
- String translate and maketrans methods
- Boost your productivity with the REPL
- set and frozenset
- List comprehensions 101
- Conditional expressions
- Pass-by-value, reference, and assignment
- String formatting comparison
To download the free book, you need to click on this link and then set the price to $0 to purchase the book. It will ask you to add your name and email and then take you to a new window where you can download the pdf. You can also buy a book for $5 to show gratitude or buy it for $13 to show more love toward the author's work. It is all up to you.
Python is popular among data professionals. We are using it to do statistical experiments, data analysis, data management, business intelligence, and machine learning. But, we don't know all of the built-in functions that can help us write elegant and effective programs. We just have a basic understanding of language, and with trial and error, we produce solutions. This kind of practice is limited to experimentation, and it will fail in the production environment.
The Pydon’ts is a well-written and fun book to read. If you are a highly driven professional, then use this book to improve your knowledge about Python’s built-in functionalities. Furthermore, you can use this book to learn to write clean and expressive code. What makes this book stand out? It includes an example of Python code from real-world projects.
Follow Rodrigo 🐍📝on Twitter, where is post a snippet of code with an explanation. Currently, he is teaching Python list comprehensions. These lessons are small, and it takes 5 minutes to understand and learn these mini-lessons.
Abid Ali Awan (@1abidaliawan) is a certified data scientist professional who loves building machine learning models. Currently, he is focusing on content creation and writing technical blogs on machine learning and data science technologies. Abid holds a Master's degree in Technology Management and a bachelor's degree in Telecommunication Engineering. His vision is to build an AI product using a graph neural network for students struggling with mental illness.