Python One Liners Book Review

by IoFAdmin at

review | python | programming

Make Your Code More Concise With One Liners

The Python language allows for writing easy to follow code but that doesn't mean it's efficient or concise. Concise code is usually easier to understand than verbose code. One liners are code that do multiple things efficiently in one line instead of multiple lines.

Python One-Liners by Christian Mayer

According to Christian Mayer in his book Python One-Liners: Write Concise, Eloquent Python Like a Professional, focusing on one-liners will help you read and write code faster and more concisely, and will improve your understanding of the language. I agree with Christian that shorter code is better than longer code as long as it's understandable.

So What Will I Learn?

There are 6 chapters in Python One-Liners with multiple code examples in each one.

  • Chapter 1 - Python Refresher: basic data structures (integers, floats, booleans, strings), container data structures (lists, sets, dictionaries, comprehensions), control flow (conditionals, loops, functions, lambdas)
  • Chapter 2 - Python Tricks: list comprehensions, reading files, lambda/map, slicing, list concatenation
  • Chapter 3 - Data Science: in depth one-liners with NumPy arrays
  • Chapter 4 - Machine Learning: linear regression, logistic regression, k-means clustering, neural network analysis, decision-tree learning, classification
  • Chapter 5 - Regular Expressions: string matching, web scraping, hyperlink analysis, string extraction, time format validation, duplicate string detection, string modification
  • Chapter 6 - Algorithms: put everything from the previous chapters to use

Who Is This Book For?

This book is not for beginners. You should at least know the basics of Python and have some programming experience because while this book does a good job of explaining the code, it doesn't handhold.

Summary

Python One-Liners: Write Concise, Eloquent Python Like a Professional is a pretty short book (just shy of 200 pages) but there's a lot in it. There's a little bit of something for every Pythonista so you can pick and choose what you need. I focused on chapters 2, 5, and 6 because those apply to me the most but everyone has different programming specialties.

So Buy It or Skip It?

I liked many parts of Christian Mayer's Python One-Liners: Write Concise, Eloquent Python Like a Professional and I found it useful.

I give it a Fire! Buy it today!