View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Python 2ed Errata

Page 46

On page 46, about 1/2 the way down, the print getPixel command should be

if you're following along the entire section's commands, since the only picture created was named myPict, not myPicture

Page 47

First introduction of a named color (black), but we hadn't discussed that yet.

Page 48

Figure 3.10: Clearly the picture comes from an earlier version of JES, where pixels[1] was leftmost, but now pixels[0] is.

Page 72

Exercise 3.19 requires a conditional so this exercise should have been moved until after conditionals have been

Page 81

Figure 4.6 should have Y=28, Y=97, X=13, X = 276

Page 117

Program 43 page 117. The “and” in the final “if statement” should be an “or”, even though the picture returned is often more interesting with an “and”.

Page 124

The chromakey2 example has
for p in pixels(source)

it should be

for p in getPixels(source)

Page 150

The example in Section 6.2.1 starts by assigning aSound but ends using the variable sound.

Page 191

Program 74 uses len but it should be getLength(target) and sourceIndex should be cast to (int) since we are adding a factor that can be a double. The test code also uses cF and testF when it should all be cF.

def shift(source,factor):
target = makeEmptySound(getLength(source))
sourceIndex = 0;

for targetIndex in range(0, getLength(target)):
sourceValue = getSampleVAlueAt(source, int(sourceIndex))
setSampleValueAt(target, targetIndex, sourceValue)
sourceIndex = sourceIndex + factor

return target

tested with:

>>> cF = getMediaPath("c4.wav")
>>> print cF
>>> c4 = makeSound(cF)
>>> lowerC4 = shift(c4,0.75)

Page 192

Program 75 page 192. The “if statement” needs a colon. I only found this since this is the first page number associated with “if” in the index.
I think the first actual use of the “if statement” is on page 102 in problem 4.2. I am trying to decide whether to introduce the conditional statement in Chapter 3 so that I can use Problem 3.19 which requires it.

It also uses len which isn't defined. It should use getLength(target), sourceIndex needs to be cast to integer, and it should use getLength(source) instead of sourceLen.

So the code should be:

def shift(source, factor):
target = makeEmptySound(getLength(source))
sourceIndex = 0

for targetIndex in range(0, getLength(target)):
sourceValue = getSampleValueAt(source,int(sourceIndex))
setSampleValueAt(target, targetIndex, sourceValue)
sourceIndex = sourceIndex + factor
if (sourceIndex >= getLength(source)):
sourceIndex = 0

return target

Page 210

"until the test becomes true" describing while should actually be "until the test becomes false."

Page 218

"return room" should be indented at the same level as "printNow" in the line above it.

Page 233

At the bottom of page 233, Chapter 10, “Later in this chapter, we map sounds …”. I don’t think that happens in Chapter 10, but rather in Chapter 11.

Page 236

Printing Unicode worked in Jython 2.1, but fails in Jython 2.2. It looks like it works in Jython 2.5, but we haven't moved JES to that yet. So the examples of printing Unicode won't work in the latest versions of JES.

Page 257

Problem 10.20 talks about the swapped keys but starts with "7" when the input text includes an "6." An additional mapping of 6 for Y needs to be included.