Book Review: Modern Python Cookbook

Packt Publishing recently released a new book called Modern Python Cookbook by Steven Lott. It’s sub-title is “133 recipes to develop flawless and expressive programs in Python 3.8, 2nd Edition”, which may give you some indication that this is a big book. In fact, it clocks in at 822 pages!

I first read Lott’s Mastering Object-Oriented Python, which is an excellent book. He is an excellent writer who can easily dive into the technical details of any topic in Python.

O’Reilly was the first company to put out a Python Cookbook. That book is good too and it’s nearly as large as Lott’s latest work. Cookbooks aren’t meant to be read cover-to-cover. But they are great for learning new nuggets of information. Lott’s book is arranged in groups of recipes. Interestingly, Packt was able to get the author of the first Python Cookbook, Alex Martelli, to be one of the technical reviewers for this one.

There are 15 chapters with a varying number of recipes in each. You will be surprised how detailed the recipes get. For example, there is a recipe called “Working with large and small integers” which sounds trivial at first blush. But after reading through it, you will learn a lot about how Python represents integers differently than other programming languages.

It also explains how sys.maxsize() comes into play which was actually much more interesting than I expected. I appreciated that the recipes have a “See Also” section that tells you where to go next to learn something related within the book or at a URL.

I like that there are recipes that explain how to use the walrus operator, forcing keyword-only arguments and position only arguments too. There’s a lot of good coverage of new features in the latest versions of Python here.

You will also learn about classes, objects and functional programming in this book.

Amazingly, the author covers web services, configuration, combining applications, statistical programming and linear regression too!

You should check this book out. It’s really interesting and will be a great reference book.