Python Developer's Handbook, alternate review


Review

I was looking forward to reading another python book, but there are too many errors in the Python Developer's Handbook, for it to be useful to its intended audience. I glanced through a few pages randomly, and saw many blatant mistakes that I am surprised the author didn't catch. Here are some examples of mistakes caught glancing just through the first 200 pages of the book:

major mistakes
p.105. The author gives an example of the copy module.

  
>>> import copy
>>> x = [1,2,3,[4,5,6]]
>>> y = copy.copy(x)

The author states here, "As you can see, this function provides the same result that y=x[:] does. It creates a new object that references the old one. If the original object is a mutable object and has its value changed, the new object will change too."

The author's statement is totally wrong, given the example he presents. In this case, y is a copy of x, and changing either one will not change the other, as the following shows:

>>> x=[1,2,3,[4,5,6]]
>>> x
[1, 2, 3, [4, 5, 6]]
>>> y = x[:]
>>> id(x) == id(y)
0
>>> x
[1, 2, 3, [4, 5, 6]]
>>> y
[1, 2, 3, [4, 5, 6]]
>>> x.append(7)
>>> x
[1, 2, 3, [4, 5, 6], 7]
>>> y
[1, 2, 3, [4, 5, 6]]
>>>

major mistake:
p.191. This example makes no sense at all, and surely, typing it in produces a traceback. Yet the author shows an answer he got as 2. Makes me really wonder, how many drinks did the author have while proofreading this book?

>>> def printGlobalcount():
	print Globalcount.n

	
>>> class Counting:
	n = 0
	def __init__(self):
		Globalcount.n = Globalcount.n + 1

		
>>> inc = Counting()
Traceback (most recent call last):
  File "", line 1, in ?
    inc = Counting()
  File "", line 4, in __init__
    Globalcount.n = Globalcount.n + 1
NameError: global name 'Globalcount' is not defined
>>> 

more subtle mistakes:
stick with the same case, for example p.186:

The class names are first mentioned as Student and NewStudent, but in the next few pages they change case, and mysteriously become student, and newstudent.

>>> studentfile.newstudent.__name__
'newstudent'

Final Word:

Overall, I have serious reservations about recommending this book to anyone but a proofreader. I found way too many mistakes in the initial analysis of the book for it to be very useful to any serious python programmer.

Overall Rating:

I give this book 2 stars out of 5.