Python 3ed Errata

p. 23: If you click 'cancel' from pickAFile, it returns None, not empty string.

P. 24: Figure 2.3 is referenced for how to see ".wav" files – but there are none in that figure.

p. 28: The example of what printing sound generates is wrong. JES prints a filename, too.

I believe there is a misleading mistake in p52 in the second paragraph. It says :

“The JES picture tool is shown in Figure 3.13. The JES picture tool works from
picture objects that you have defined and named in the Command Area. if you don’t
have the picture named, you can’t view it with the JES picture tool. p = makePicture
(pickAFile()) will allow you to define a picture and name it p. You can then explore
the picture using explore(pict (should be p)) or you can choose PICTURE TOOL…"

Dave Largent, BSU

From Susan Schwartz at West Point:

P. 52: Captions for Figures 3.13 and 3.14 should be swapped.

P. 56: Stray reference to "recipe" instead of "program"

P. 65: "filename = makePicture(filename)" in reduceBlue should be "picture=makePicture(filename)"

P. 69: Another recipe reference

Pages 63-65: The Example Program 13 got its name changed to makeSunset2, but the references in the text on pages 63-65 still say makeSunset.

Sigh

On page 76, the example mentioned for the square bracket stuff (e.g. [0,3]..) should actually
be [0, 1, 2]. The 0, 3 are the arguments for the range function, not the array produced.

John Rutkiewicz, UMass Dartmouth

_
From Susan Schwartz at West Point:

Page 78: Both Step 9 and 11 says that y goes to the height of the picture. It doesn't – it stops at height-1.

P. 79: Last paragraph says that x goes to mirrorPoint (it doesn't – it stops at mirrorPoint-1), and y goes to the height of the picture (again, minus one).

P. 85: X goes 27 to 96 (not 97), and x goes 13 to 275 (not 276)

P. 86: A normal page is 8.5x11, not 9x11.5.

P. 89-91: Coordinates for Barb's face are off-by-one

P. 96: 4th bullet - target is at 200 (not 300)

p. 99: Figures are wrong. Target should end up 2,4,6 and 1,3,5.

On page 96, you use return(canvas). Although this does work fine in JES, all other programs use return canvas without the parentheses. I don’t believe that python.org shows return using parentheses either. This is also done in Programs 36 and 37 on pages 110 and 111.It's true – I wrote my early Python code with a distinct accent. As you say, the code will work with or without parens.

John Rutkiewicz, UMass Dartmouth

From Susan Schwartz at West Point:

p. 102: Missed that ranges end at 1 less than the final value.

On page 110, Program 36 uses setColor(px, redness, blueness, greenness) but should be
setColor(px, redness, greenness, blueness) to keep the green and blue colors the same. I think that if you assign redness, greenness, then blueness in that order before setColor is used, the problem may have been avoided. I could see a student making that same mistake as a result of the order.

John Rutkiewicz, UMass Dartmouth

From Susan Schwartz at West Point:

Page 111: Don't need the int() computing redness. There are no floats.

P. 111: "red" is pre-defined. Don't need to define it again.

P. 112: "black" is pre-defined.

In Program 42 on page 118, both the for x and for y loops fall short by 1 pixel in the range function because they both subtract 2 from the source width and height. x should range from 1 to getWidth(source)-1 and y should range from 1 to getHeight(source)-1 as indicated in the paragraph on page 119. If not, the edge pixel as well as the one before it will not be changed.
On page 118 at the top it states that to blur we will set each pixel to a color that is the average of the colors of the pixels around it. Program 42 actually includes the pixel itself in that average. It would be clearer if the last sentence of the second paragraph read as “What we do is set each pixel to a color that is an average of its color and the colors of the pixels around it.

John Rutkiewicz, UMass Dartmouth

In the last paragraph on page 120, it states that "In the program below, we compare each pixel's luminance to the pixel below it and to the right of it." the word "pixel" should be "pixels", but I feel that it would be clearer to the reader if it stated "the pixel below it and the pixel to the right of it."

John Rutkiewicz, UMass Dartmouth

On page 121, the 2nd bulleted item in How It Works states that "We use indices for x and y from 1 to the ...". Program 43 shows the indices for x and y starting at 0. We're starting at the first pixel but that is at an x and y index of 0.

John Rutkiewicz, UMass Dartmouth

One day, we'll catch all the zero/one index issues...

From Susan Schwartz at West Point:

p. 125: Don't need to return pic1 since it's an input.

On page 130, the header in Program 48 reads as def chromakey2(program, bg) but should be def chromakey2(source, bg).

John Rutkiewicz, UMass Dartmouth

In program 49 on page 132, the function horizontalLines should have the y loop first and the x loop nested within it. It should be as follows:

P. 132: Program 50 talks about "beach-smaller.jpg" which is missing from mediasources. Fix to use beach.jpg.

On page 135, the reprint of Program 41 is missing parentheses around the two conditions as in the original Program 41 on page 117.
Parentheses also missing around the condition in program 52 on page 136.

This actually works fine. It's different style than what we use elsewhere in the book, but it's not incorrect.

This one's minor but for consistency you may want to change the function name in Program 51 from "littlepicture" to "littlePicture".
In the third bullet of problem 5.1, page 140, the function name
should be changeColor, rather than changeRed.

Peter J. DePasquale, Ph.D., Associate Professor, Department of Computer Science, The College of New Jersey

but does not include it in the problem statement.

Peter J. DePasquale, Ph.D., Associate Professor, Department of Computer Science, The College of New Jersey

From Susan Schwartz at West Point:

P. 221 and 223 have wraparound lines, but the typesetter didn't put the "wrap" characters in.

P. 225-226: Still with the "recipes"

P. 235: The algorithm speed chapter is Chapter 14, not 13.

P. 273-276: The Facebook example (program 98) was broken by the latest changes to Facebook.

An explanation of how it broke, and a new Facebook example program are available in the Powerpoint for Chapter 11: http://coweb.cc.gatech.edu/mediaComp-teach/uploads/55/Ch11-AdvancedTextTechniques-3e.1.pptUPDATE 12 March 2013: Simon (University of Newcastle) discovered that Facebook changed its favorites mechanism again, and shared with us his Facebook Favorites Access
Eva Heinrich (Massey University) just pointed out a big bug in the object-oriented programming chapter of the Python 3ed book – specifically, the SmartTurtle class, page 384 and program listing 148 (also in the 3rd edition lecture slides) which doesn't work. Barb and I thought that Python had method overloading, and we wrote an example with the two methods – but didn't test both methods. What's in the book "works," but not if you try the other method. Eva came up with this nicer fix (below). For the fourth edition...