Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Clean Python : elegant coding in Python
Kapil S., Apress, New York, NY, 2019. 284 pp. Type: Book (978-1-484248-77-5)
Date Reviewed: Jan 2 2020

Every beginning programmer needs a friend to look over their shoulder at their screen and give advice on how to code better. This book attempts to be such a friend. The book is full of advice of the kind, “do this, don’t do that.” This could be infuriating when a smart-aleck friend does it, even if you must admit that the advice is good and useful in the long run.

The author obviously has extensive experience in not only programming in Python, but maintaining programs (even those written by others). His preference is for direct, easy-to-understand code, though perhaps more verbose than needed. Some application-oriented coders who learn Python late in order to basically hack a solution might not be au fait with how to code classes and modules and more advanced features such as generators and iterators. Here, the author gives very pragmatic advice based on code snippets, emphasizing both the “wrong way” and the “better way” of writing or structuring code.

Reading such advice from a book instead of from an on-screen paperclip or listening to it from a friend will arguably be less intrusive or irritating, but at the cost of being possibly less immediate and apt. For me, it is not clear what is the best way to use this book. It is neither a reference book nor a tutorial. It seems to be best suited for new programmers who have gotten over their relief and maybe joy from getting a working program, but who then have the important but often neglected task of polishing the code while the details are still fresh in their mind.

Using the book effectively is hindered by poor organization. The structuring into chapters is clear and intuitive, but the sections and subsections seem jumbled and don’t seem to follow any logical order. The index is extremely short for a book like this, which could be very helpful if you are trying to write some code that uses some feature of Python and would like some advice on how best to structure the code. The typesetting is rather pedestrian, especially when there are big blocks of code. It would be very useful to use some better formatting and typesetting, such as provided by the minted package.

The book could probably be read from start to end, at least superficially, but there is a risk of being turned off by the first chapter, which I feel is the weakest--it assumes too much knowledge. For example, page 2 recommends using non-mangling names, but the idea of mangling is not even introduced. What is “camel case” (p. 5)? There are many references to writing “Pythonic” code without explaining this clearly. It might be good to summarize the Zen of Python instead of just including a reference to a web page. Luckily, the quality of the writing improves later on in the book.

Overall, this book can be of real help to Python programmers who would like to develop a better and more robust coding style. It covers a lot of ground, and the help it provides is of a very pragmatic nature. What I think is very important is that it acknowledges the way many people learn programming, especially in Python: not as an academic subject with carefully planned exercises to teach and assess concepts and good practices in a didactic way, but as a tool to get results, whether by adapting code snippets found on the web or inherited from colleagues, and with a coding style developed after many mistakes and maybe negative feedback from others who need to use, read, or maintain the code. In that sense, the book fills an important gap in the bookshelves of many Python programmers.

More reviews about this item: Amazon

Reviewer:  Sara Kalvala Review #: CR146824 (2005-0093)
Bookmark and Share
  Reviewer Selected
Featured Reviewer
 
 
Multiparadigm Languages (D.3.2 ... )
 
 
Languages (D.2.1 ... )
 
 
Tools (D.2.1 ... )
 
Would you recommend this review?
yes
no
Other reviews under "Multiparadigm Languages": Date
A declarative debugger of incorrect answers for constraint functional-logic programs
Caballero R.  Curry and functional logic programming (Proceedings of the 2005 ACM SIGPLAN Workshop on Curry and Functional Logic Programming, Tallinn, Estonia, Sep 29, 2005)8-13, 2005. Type: Proceedings
Dec 22 2005
Learn to Tango with D
Bell K., Igesund L., Kelly S., Parker M., Apress, 2007.  208, Type: Book
Aug 20 2008
Programming Scala: scalability = functional programming + objects
Wampler D., Payne A., O’Reilly Media, Inc., Sebastopol, CA, 2009.  448, Type: Book (978-0-596155-95-7), Reviews: (1 of 2)
Jun 11 2010
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy