Pro Python |
Author: Marty Alchin
Python isn't a difficult language but it does have a lot of subtle and fairly advanced facilities. Once you have mastered the basics there can still be a long haul up the slope to learn how to do things properly. This book aims to give you a big push. However before you rush out and buy it you need to know that it is all about Python 3, and while there are plenty of references to how things have changed this is really only for Python 3 programmers.
The book starts off with a look at the Zen of Python. Essentially these are the philosophical principles that should guide a Python programmer. If you want to get into Python it is by no means essential that you sign up to all of these principles and in fact there are a few that I would argue with - even though the majority are common sense. The book properly starts at Chapter 2 with a mixed collection of "Advanced Basics". There is no particular logic to this chapter it just rambles through exceptions, loops, the with statement, list comprehensions and so on. There are occasional notes on how things have changed prior to 3.0 and the occasional quoting of principles from Chapter 1. What you make of the chapter depends very much on how well you know Python 3.0. There isn't much in this chapter that would come as a revelation if you simply learned the basics of each topic - but if you haven't covered the ideas it's a useful random walk. The next chapter deals with functions - basically different ways of creating clever functions with different types of parameters, using closures, decorators, generators, lambdas and so on. The chapter includes a lot of bigger examples but if you are not already familiar with the idea of closure or generator say then you might find the treatment a bit on the brief side. From functions we move on to classes with a look at inheritance and multiple inheritance in particular. Python is one of the few modern languages to make a virtue out of multiple inheritance and much of the chapter is spent on explaining the why and how of using it correctly. The change in the way objects are handled is perhaps one of the biggest changes in version 3.0 and there are lots of compatibility notes. Chapter 5 is called "Common Protocols" and it is a strange collection of how to implement custom behavior in ways that fit in with the existing types. It explains how to override operators and the behaviour of fundamental types. The next chapter deals with another vague topic - object management - which is all about namespaces, garbage collection and pickling, shallow and deep copies. Chapter 7 is a close look at strings. - encoding, formatting, conversion and so on. From this point the book moves off into more general territory. Chapter 8 seems to be about documentation but it is also about writing code that self documents. Then we move on to test driven development and Chapter 10 is about distribution of Python programs. Chapter 11 is a bit odd as it is a case study - Sheets a CSV framework - which is all about converting files to Comma Separated Value format. The book is rounded off with the republication of a set of PEP texts - which are freely available on the web - and use up some 30 pages. Overall I enjoyed reading this book. If you want a sort of advanced Python reader almost just to check that you understand Python well then this isn't bad. It doesn't have a particularly logical structure and occasionally it could spend more time explaining difficult ideas but overall it does cover a lot of advanced Python. The book runs out of steam a bit towards the end with coverage of general topics and it has some padding but if you want an advanced Python reader then it's not bad.
|
|||
Last Updated ( Thursday, 26 May 2011 ) |