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

Python 3ed Errata

See Susan Schwartz's Detailed Comments on 3rd Edition


From Susan Schwartz at West Point:

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…"

From Susan Schwartz at West Point:


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.
_
From Susan Schwartz at West Point:

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.

From Susan Schwartz at West Point:

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.

From Susan Schwartz at West Point:

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.


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."

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.
One day, we'll catch all the zero/one index issues...

From Susan Schwartz at West Point:

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

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:
def horizontalLines(src):
  for y in range(0, getHeight(src), 5):
    for x in range(0, getWidth(src)):
      setColor(getPixel(src,x,y), black)


From Susan Schwartz at West Point:

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.



but does not include it in the problem statement.

From Susan Schwartz at West Point:


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.ppt
UPDATE 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...

class SmartTurtle(Turtle):
   
def drawSquareMod(self , width = 100):
    for i in range (0 ,4):
      self.turnRight ()
      self.forward(width)
 

earth = makeWorld()
sm = SmartTurtle(earth)
sm.drawSquareMod()
sm.drawSquareMod(200)


But there's no such thing as a pyramid wave! Clearly should have said triangle or sawtooth.
8.9 Write a function to create a pyramid sound wave.