The "Writing Idiomatic Python" book is finally here! Chock full of code samples, you'll learn the "Pythonic" way to accomplish common tasks. Each idiom comes with a detailed description, example code showing the "wrong" way to do it, and code for the idiomatic, "Pythonic" alternative. *This version of the book is for Python 2.7.3+. There is also a Python 3.3+ version available.* "Writing Idiomatic Python" contains the most common and important Python idioms in a format that maximizes identification and understanding. Each idiom is presented as a recommendation to write some commonly used piece of code. It is followed by an explanation of why the idiom is important. It also contains two code the "Harmful" way to write it and the "Idiomatic" way. * The "Harmful" way helps you identify the idiom in your own code. * The "Idiomatic" way shows you how to easily translate that code into idiomatic Python. This book is perfect for * If you're coming to Python from another programming language * If you're learning Python as a first programming language * If you're looking to increase the readability, maintainability, and correctness of your Python code What is "Idiomatic" Python? Every programming language has its own idioms. Programming language idioms are nothing more than the generally accepted way of writing a certain piece of code. Consistently writing idiomatic code has a number of important * Others can read and understand your code easily * Others can maintain and enhance your code with minimal effort * Your code will contain fewer bugs * Your code will teach others to write correct code without any effort on your part
"Writing Idiomatic Python 3" attempts to uncover the elegance of Python3 syntax; what programmers call 'Pythonic code'. Python has plethora of cool ways to trim down and beautify code. This book deals with them one by one.
What I liked I learned a lot of "hidden" features..well, hidden for beginners/intermediate users at least, some of which follow: - Use of iterable to avoid repetition of value comparison. Sample: if name in ('Tom', 'Dick', 'Harry') - Use of enumerate() function to eliminate maintenance of an explicit index variable in a loop. - * operator to represent "rest" of a list while unpacking it. - Along the same line of unpacking, use of '_' as a placeholder to ignore an unpacked value. - Clever use of set to eliminate duplicate entries from an Iterable. - Swiss knife for Iterables: itertools module
What I disliked I object against avoiding explicit comparison to None. Agreed, the author has pointed out an exception where one should explicitly compare with None. However, I find it safer to be consistent. Also, I find it a bit aggressive to use the title "Harmful" in order to depict the non-recommended code sample. I would rather prefer terms "Pythonic" and "UnPythonic". I expect some more logical organization of Python features in future editions.
Recommended Audience This is a must-read book for people who are acquainted with Python. Complete beginners, however, might find it difficult to keep their heads above water. It kind of hangs in between post-beginner and advanced levels. I would strongly recommend this book to the Java/c# immigrants. With such a short Pythonic reference in hand, they should feel themselves at home. Even those who have been writing in Python since long, but are still unaware of Pythonic style of writing code, could find this book an enlightening read.
As a on again/off again python developer .. this book really helped in keeping my code as clean as possible. Best part is that the book is short and quickly to the point. The TOC is well organized as well. Probably made me feel better than anyone else reading my code.
This is a really quick read and a good refresher if you are already experienced with and switching to python from another language.
Probably not the right book if you are a beginner who is unfamiliar with programming in general or, on the other hand, are looking for something very in depth.
We live in an exciting time. The power of programming, once exclusive to socially outcast nerds living in their parent's basement, is now mainstream. Online courses and tutorials make it easier than ever to learn how to code.
Let us pause and reflect on the fact that every man, woman and child in modern society have a machine of infinite imagination and limitless potential at their fingertips.
As programming becomes more popular, more code is written, and subsequently more bad code is written. It is therefore crucial to create programming conventions to ensure code is readable and maintainable.
That is Jeff Knupp's mission in his book Writing Idiomatic Python.
This book is a short and sweet (you can easily finish reading in one sitting) set of best practices for coding in Python, without a morsel of fluff. It is not meant to be comprehensive, rather it aims to show through examples how one writes idiomatic Python code , i.e. code that is "pythonic" .
Beyond the nitty gritty details, Knupp provides meta programming tips which are both insightful and practical. For example, Python uses modules to encapsulate data and therefore relies less on object-oriented paradigms than other languages (such as Java, C++ etc.).
The style is concise and easy to understand. I appreciated the humorous code examples which made the dry topics more palatable. Knupp elucidates each point by giving the harmful and correct approach to use case scenarios.
There is something beautiful about well written code, similar to that of mathematical proofs. We don't just want to solve a problem, we want to solve a problem in the simplest way possible. This book doesn't show us how to solve problems; it shows us how to communicate solutions.
Highly recommended for Python developers experienced and new, Writing Idiomatic Python will teach you how to write code that is clear, elegant and of course, idiomatic.
Favorite Quote:
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." —John Woods
At under 70 pages, it's a quick and easy read, following a fairly consistent format of advice heading, advice description, "harmful" code example and "idiomatic" code example. Recommended for those experienced in another programming language moving that knowledge to Python and/or those wanting to improve existing Python knowledge, i.e. it's not for beginners to programming.
Layout is rudimentary which is a bit of a letdown when compared to the web pages selling the book. By itself that isn't a big deal, but when compared to, e.g., a recent similar eBook I bought (Two Scoops of Django) it left me wondering if it offered enough value for the price. Thankfully I was satisfied if I came away with just one or two good pointers that improved my code so it was of value to me.
The book is succesfully achieving my goal of bringing me up to speed on Python. I've been coding for almost 30 years now and I've done considerable amount of Python but not in the last 8 years. I wanted a book that would bring me up to speed on the right Pythonic way of doing things these days. That bit it's working.
Having said that, the book has some issues. There are quite a few typos and at least one code snippet that seems to have been updated without updating the text talking about it. I could see the text and the snippet where explaining the same thing, but they were different. There are a couple of code example where I think 70% of the code is not relevant and distract from the 30% that matters. This is a bit sad because I think the content is good and I learned a few things I never knew about Python.
This book is not for complete beginners, it's for people that has been coding in python without a formal introduction coming for other languages perhaps. It helps you to be a real pythonist by doing the same things in the same way that pythonists are using. The code examples are very clear and concise and do a great job making clear what the text is explaining. Recommended book for those who want dive further in development with python.
This book is has high 'utility density', a term I just made up to measure the amount of information I will likely use within the next year per word.
Here are three things I learned: - PyPI has a lot of useful packages. Learn them. - Use _ as a placeholder for data in tuples that should be ignored - Avoid using mutable objects as default values (when using keyword arguments).
As a principally ruby developer coming to Python, this is a really handy guide to (as you might expect) pick up the idioms you would have internalised if you had only been writing in Python your whole career
Highly recommended! It's one of the best books you can get once you have a basic Python understanding, it teaches you the right way to do some stuff, it teaches you some aspect of the language that I didn't even knew existed. Worth the 8 euro!
I love the simplicity of this book. I love that it is direct and to the point and wastes no time with fluff. These are specific recommendations that are easy to implement because they have been stripped down to the exact point they intend to make.
I'm a complete Python rookie, but was still able to pick up a lot of hints from this book. As a result, I feel more confident in my Python skills. Good stuff!
This book is just eye opening if you are a Python intermediate. Recommend reading for anyone who coded already a little bit because then you will appreciate the way how the ideas help you (and understand what is going on, because the book does not waste time explaining the basics of Python). Also, love Knupp's recommendation to use _ as a placeholder for ignored input (yaay ("\(^_^)/") Prolog).