Python 2ed Errata
Page 46
On page 46, about 1/2 the way down, the print getPixel command should be
- print getPixel(myPict, 0, 0)
if you're following along the entire section's commands, since the only picture created was named myPict, not myPicture
- Submitted by Monica McGill
Page 47
First introduction of a named color (black), but we hadn't discussed that yet.
- Submitted by Monica McGill
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
covered.
- Submitted by Barbara Ericson, Georgia Tech
Page 81
Figure 4.6 should have Y=28, Y=97, X=13, X = 276
- Submitted by Barbara Ericson, Georgia Tech
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”.
- Submitted by Dominic Soda, Lindenwood University
- Tom Whaley also noted that it's possible for both tests to fail in Program 43.
Page 124
The chromakey2 example has
for p in pixels(source)
it should be
for p in getPixels(source)
- Submitted by Barb Ericson and found by Leslie Spivey
Page 150
The example in Section 6.2.1 starts by assigning aSound but ends using the variable sound.
- Submitted by Tom Whaley, posted by Mark Guzdial
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
play(target)
return target
tested with:
>>> cF = getMediaPath("c4.wav")
>>> print cF
c:/ip-book-mediasources/c4.wav
>>> c4 = makeSound(cF)
>>> lowerC4 = shift(c4,0.75)
- Submitted by Leslie Spivey, posted by Barbara Ericson
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.
- Submitted by Dominic Soda, Lindenwood University
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
play(target)
return target
- Submitted by Leslie Spivey, posted by Barbara Ericson
Page 210
"until the test becomes true" describing while should actually be "until the test becomes false."
- Submitted by Mark Guzdial
Page 218
"return room" should be indented at the same level as "printNow" in the line above it.
- Submitted by Mark Guzdial
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.
- Found by Tom Whaley, posted by Mark Guzdial.
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.
- Submitted by Mark Guzdial, notice by Jay Summet