Community Reviews. Showing Average rating 4. Rating details. More filters. Sort order. Start your review of Writing Idiomatic Python 2.
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..
Sample: if name in 'Tom', 'Dick', 'Harry' - Use of enumerate function to eliminate mainten "Writing Idiomatic Python 3" attempts to uncover the elegance of Python3 syntax; what programmers call 'Pythonic code'. Sample: if name in 'Tom', 'Dick', 'Harry' - Use of enumerate function to eliminate maintenance of an explicit index variable in a loop. 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. 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.
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.
It's easy and quick to read, and having examples of everything is great. A little bit basic for anyone who had spent some time using Python and has worried about "doing things right" 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. Dec 16, Bonface M.
This book was pleasantly short and was packed with relevant and practical advice for people getting into python! Dec 18, Joshua rated it really liked it Shelves: programming , 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 We live in an exciting time. It is therefore crucial to create programming conventions to ensure code is readable and maintainable. 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. Beyond the nitty gritty details, Knupp provides meta programming tips which are both insightful and practical.
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.
Python 2 and 3: raise ValueError "dodgy value". Python 3 only: raise ValueError "dodgy value". Python 2 and 3: option 2 from future. Setup: class DatabaseError Exception : pass.
Python 2 and 3: from future. Python 2 only: try Python 2 and 3: try Python 2 and 3: from past. Python 2 only: if isinstance x , int , long Python 3 only: if isinstance x , int Python 2 and 3: option 1 from builtins import int subclass of long on Py2 if isinstance x , int : matches both int and long on Py Python 2 and 3: option 2 from past.
Python 2 and 3: alternative 2: refactor the code to avoid considering byte-strings as strings. Python 2 only: import submodule2. Python 2 and 3: from. Python 2 only: for key in heights. Python 2 and 3: for key in heights Python 2 only: for value in heights. Idiomatic Python 3 for value in heights. Python 2 only: for key , value in heights.
Python 2 and 3: option 1 for key , value in heights. Python 2 and 3: option 3 from future. Python 2 and 3: option 4 from future. Python 2 and 3: backward-compatible from past. Python 2 and 3: backward compatible from past. Python 2 and 3: option 3 try : import itertools.
Python 2 and 3: option 5 from past. Python 2 and 3: option 2 try : import itertools. Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience. Note: A newer bugfix release, 2. Its use is recommended over previous versions of 2.
Python 2. The Python 2. The 2. Improvements in this release include:.
0コメント