By Developers, For Developers

Historical errata for Practical Programming

PDF PgPaper PgTypeDescriptionFixed onComments
20TYPO

Phrase ‘Larger than than’ is used. I believe it should read ‘Larger than that’.

2009-02-03
27ERROR

At the top of the page is a function definition ‘fahr_to_cel’.

This is further enforced by the comment ‘We use a readable name like fahr_to_cel for the function, rather
than something like f whose meaning will be hard to remember…’.

At the bottom of this page the example usage of this function uses the function name f() rather than fahr_to_cel().

2009-02-03
27TYPO

The function fahr_to_cel is defined.

The text then explains that fahr_to_cel is a better name than f, because it’s good style and f will be hard to remember.

However, the example then calls the function as f…

>>> f(80)
26.666666666666666

2009-02-03
34TYPO

In 8 a), litres and liters spellings are both used.

2009-02-03
61ERROR

The media.py is not included in the download mentioned on page 57 and the reader is not given any idea what to do..

2009-02-03
44TYPO

Third list item: “input can be provided b the user” should be “input can be provided BY the user”

2009-02-03
54TYPO

Under Using main heading: every Python file can can be run

2009-02-03
67SUGGEST

4.5 Testing

There’s no mention of needing to download nose, and doesn’t even provide an address to do so.

2009-02-03
61SUGGEST

This section is very confusing. I downloaded a few different versions of Pygraphics but none of them provided me with the media.py.

There’s no instruction on how to install it (which turns out it’s pretty simple, but confusing when it’s installed and you still can’t get the media module to work.

I eventually managed to get the section working by using the functions from the pictures module.

FYI - I’m on Mac OSX 10.5, using Python 2.5 (also tested 2.6).

2009-02-03
42TYPO

print "%f rabbits are in cage #d." (rabbits, number) the number variable is wrong it should be cage

2009-02-03
42SUGGEST

“As we said before, print automatically puts a newline at the end of a
string. To prevent this newline from being added, put a comma at the
end of the line:”
I would suggest revision of the paragraph.

2009-02-03
55TYPO

Typo on the bottom of page 55 (PDF) in the function definition:
‘dinosar’ should be ‘dinosaur’

2009-02-03
61SUGGEST

The tools for using examples in this book are packaged as part of the class site maintained by the book authors: www . cdf . toronto . edu / ~csc108h / fall / python.shtml (sorry for the formatting but it is not possible to submit URLs as part of the erratum). This link to the software installers should be provided within the book.

2009-02-03
19TYPO

Sect 2.3: end of 2nd. paragraph: double period -> it should be a single period.

2009-02-03
27SUGGEST

After explaining the syntax of a function definition you recall the advantages of Wing over NotePad or Pico:

“This is another reason to use Wing instead of a plain ol’ editor like NotePad or Pico”

A novice reader could get the wrong impression that all plain and old text editors have similar limitations. You know that vi(m) or emacs excel in helping programmers to indent code properly and seamlessly. A more precise delimitation of “problematic” editors would be welcome.

2009-02-03
28TYPO

functions calls t(80) and similars should be fahr_to_cel(80), … This typo was already reported for page 27.

2009-02-03
29TYPO

Wrong figure: figure 2.9 - local variables. The corresponding text refers to the function polynomial: the figure is misleading.

2009-02-04
129TYPO

There is a ‘by’ between what should be the second and third sentences of the first paragraph. It should be replaced with a period.

2009-02-03
42TYPO

/case/cage/
“17.000000 rabbits are in case #10.”

2009-02-03
52ERROR

Shouldn’t the function have the Module name as a preface?

temperature.above_freezing(temperature.fahr_to_cel(33.3))

2009-02-04
61ERROR

The media module referenced on line 17 doesn’t exist in all linux distribuitions, I’m using Ubuntu 8.04.1. In general the module has to be downloaded from pymedia.org and built, there seems to be a Debian package that doesn’t get rave reviews. In order to build the package you have to have gcc-3.4 and g–3.4. These are both installable on Ubuntu 8.04.1, but the build fails on a 64bit system due to a problem with g+3.4. The following reference gives directions for installing pymedia on an 8.04.1 32 bit box, but as can be seen from the comments it presents a problem on newer versions of Ubuntu. These problems should be addressed either by an optional method to accomplish the same task or by a fix to the problem besides relinking the softlink in /usr/bin from g4.2 to g3.4. Even ’export CC=gcc-3.4 and CXX=g+–3.4’ doesn’t work on a 64 bit system. I’m sure given time I can hack my way through this, but since this is supposed to be a book for beginning programers I think this could be considered a major faux paux.

2009-02-28
61SUGGEST

Now for the social commentary. On the authors website, the only sources available are for Windows and MacIntosh. Makes one wonder.

2009-02-28
188OK

Two reasons for looping over the keys of a loop are given. However, the most important (that keys are guaranteed to be unique, while values aren’t) isn’t given.
For that matter, I don’t believe that concept is covered (not up to this point, anyway).

2009-02-28
237OK

“Here, the statements in the else block are only executed if everything
inside the try block was executed without error. If we were sure we
knew all the places that exceptions could be thrown, we could put these
statements inside the try block.”

This is ambiguous. “[T]hese statements” seems to refer to the statements in which exceptions could be thrown, although it is supposed to refer to the statements which we know will not throw an exception.

2009-02-28
250SUGGEST

The sample code on this page uses the variable ‘time’. It may be worth noting (here and during discussions on modules) that ‘time’ is also the name of a standard module, and if you’ve imported the time module, you’ll overwrite it here. Same goes with ‘file’ and others, of course.
(That’s one of my pet peeves with Python—these should be initial caps, at least.)

2009-02-28
251ERROR

The script (construct/largethresh.py) has a bug:
‘if not result:’ will behave improperly if result is 0, which is a valid answer.

2009-02-28
335OK

when you talk about creating temporary names for the tables, you should mention that most databases use the ‘select * from PopByCountry as A’ syntax.
I’m not too familiar with sqlite, but if it can use the ‘table as alias’ syntax, it would be better to be explicit.

2009-02-28
148TYPO

Subsection 7.5 Style Notes, there is statement:
When the there are multiple paths…
“the” should be deleted.

2009-02-28
59TYPO

Figure 4.3: Common String Methods, there are two descriptions of split() method. Declaration for the second one most probably should be: split(del)

2009-02-28
8OK

I am pressed for time and would really like to get my hands on suggested solutions for at least some of the exercises.

Is this a no-no to wish?

And if not, how can I go about wishing it and getting my wish fulfilled?

PS: (The choice of page 8 - the end of the TOC - was arbitrary!)

2009-02-28
183SUGGEST

In the table you have the two columns Method/Example and Purpose/Result then in the content you write for example “Adds an element to a set” and “None”. I think this could be quite confusing for beginning student since the first line suggests that using ‘add’ would add something to a set but then the example line ‘add(9)’ says that the result was None.

I think it’s pretty difficult for a novice to distinguish between the textual description, the expected result of the operation (that lows now contains a 9 also) and the return value from the operation.

I would suggest that you make this much much clearer.

2009-09-09Per typeset - not possible - won't fit on the page
102TYPO

Exercises 6 & 7 are identical.

2009-09-09
25SUGGEST

Page 25 code example (and Figure 2.7) use a variable identifier named
‘double’. While this is descriptive, it is perhaps not the best
choice. We are using Python as a gateway language into Java or C down
the line (next semester) and using a variable identifier that is a
common type identifier in many other languages could be confusing.

2009-09-09
108TYPO

Figure 6.3: 2nd diagram
The expression 3 and 0. 0 should be “False” (not True as listed) so the overall expression evaluates to False (or 0).

2009-09-09
122TYPO

problem 11: the code snippet “if pH < 7.0”. The variable name should be ph instead.

2009-09-09
123TYPO

Preceding the paragraph “Why does the last example…..” should be given problem #12.

2009-09-09
340TYPO

Last Paragraph:

“For example, imagine what would happen in a database
Dusing a hospital’s name as a primary key if the hospital changed its
name.”

Should read:

“For example, imagine what would happen in a database
using a hospital’s name as a primary key if the hospital changed its
name.”

2009-09-09
26SUGGEST

An answer key for the exercises presented in the book. This can be posted online for the current edition and in the back of the book for future editions.

2009-09-09
55ERROR

when following the instruction:“import media” in the exemple, Python return an error message:“Traceback (most recent call last):
File ”“, line 1, in
ImportError: No module named media”

Same thing happen when I use Python IDLE… Is there something I forgot?

2009-09-09
162TYPO

read_file_4.py is missing ‘import sys’ (in pdf and file downloaded from website.

2009-09-09
172ERROR

When summing the monthly values to calculate the yearly totals, the slices should be [12:24] and [0:12], not [12:23] and [0:11] (unless builders take December off!)

2009-09-09
173TYPO

The tuple for the yearly totals should be (46.400000000000091, 17.577000000000027). (see errata marked as p172)

2009-09-09
339TYPO

Duplicates are for “North America”, as the list in the code snippet shows, not for “Eastern Asia”

2009-09-09
339ERROR

Code snippet db_distinct.cmd does not contain the DISTINCT command!

2009-09-09
59TYPO

Cross reference for color type and color values should be Figure 4.8 on the same page, not 4.3 on page 53.

2009-09-09
13ERROR

In figure 2.4, the result of 8.5 * 2.5 is given as 29.75.
The operand 2.5 should be corrected as 3.5 or the result 29.5 corrected as 21.25.

2009-09-09
20ERROR

I have defined the function to_celsius, and entered the formula on the next line. How do I exit this in order to call the function?

2009-09-09
24SUGGEST

Rewrite last sentence before section 2.8 for coherence.

“In this example, we see that when a floating-point number is converted to an integer and truncated, not rounded.”

2009-09-09
45SUGGEST

Section 4.2 begins, “Section 2.1, The Big Picture, on page 7 explained that in order to save code for later use, you can put it in a file with a .py extension.”

There is no such explanation in Section 2.1.

2009-09-09
39SUGGEST

Chapter 3 Strings Excersice 6 appears to broach a topic that was not discussed previously in the chapter. Explicitly boolean evaluations of strings. Judging by the output I get on the Wing IDE, I am guessing that it is actually evaluating the ASCII or ANSI values of the string, but ASCII or ANSI has not been explained previously in the chapter nor is boolean expressions using == >= <= and so on. Little confusing. Even for someone who has been around this stuff a little bit. Just seems a bit premature exercise.

2009-09-09
69TYPO

Exercise 2.
c) “Read the description of the function isLeap. Use isLeap…”
isLeap should be isleap (all lower-case)

2009-09-09
32TYPO

Isn’t ‘123’ + 4 on p32 supposed to be something like
‘123’ + str(4)?
p31 has ‘123’ + 4 as an example of what doesn’t work and it seems like
the text just before this (same) line on p32 is getting ready to show me the way to convert the 4 to a string to combine it with ‘123’

2009-09-09
34ERROR

The book states that Mac OS X (implicitly always) uses ‘\\r’ as the newline character. This is inaccurate.

It is true that the standard newline character in “Classic” Mac OS (before Mac OS X) was ‘\\r’, and that this behavior carries over into many Mac OS X applications built with the “Carbon” API framework, especially those built on legacy codebases. However, the number of such apps is rapidly dwindling: newer Carbon apps and all apps built with the “Cocoa” API framework use the Unix standard ‘\
’ for newline by default.

2009-09-09
79ERROR

Example at bottom of page (lists/plus5.cmd):
>>> 0 <= i < len(half_lives)
Forward reference to relational operators, Boolean type, and comparison chaining in Chapter 6.

2011-01-19
99ERROR

Chapter 5 (Lists), Exercise 19:
for i in range(len(values[0])):
Forward reference to range() which is not discussed until Chapter 7, pages 126-129

2011-01-19
5ERROR

“… installers for Windows, Mac OS, and Linux.” “Mac OS” should be “Mac OS X”. While it is true that the Classic Mac OS was reasonably well supported back in its day, current versions of Python are only available for Mac OS X.

2011-01-19
8OK

… and more portable across operating systems…" You haven’t defined “portable” before using it here, and although it is possible to get the gist of it from the context, and I’m not sure how well known the term is outside of the CS community. Perhaps "…more portable (i.e., transferable)…

2011-01-19
15TYPO

Fig 2.5. Missing comma between “+” and “-”. The previous line uses commas to separate the multiplication, division, and remainder operators.

2011-01-19
13SUGGEST

“Python claims the result is 194.22222222222223^2 degrees Celsius” The superscript “2” is supposed to be a footnote, but at a glance it can also be interpreted as an exponent, because it immediately follows another number. I’m not sure the best way to fix this; perhaps moving the footnote so that it is on the word “Celsius” rather than on the number.

2011-01-19
21SUGGEST

“Finally, the return statement has this general form: return expression” Taken with the preceding paragraphs, this phrasing seems to imply that a return statement was in the “general form of a function definition” that appears above, which is not the case. Perhaps “Depending on the purpose of the function, its last statement may be a return statement, which has this general form: …”

2011-01-19
22TYPO

“… of the polynomial ax^2 + bx + c into several …” There is a font glitch on the “x” in “ax^2”.

2011-01-19
29ERROR

“… that represents text, such as the words in this sentence or a strand of DNA.” Science quibble: technically, a stand of DNA is not made up of text; it is made up of nucleic acids, which we humans normally label with one of four characters. Perhaps “… or the letters in the sequence of a strand of DNA.”

2011-01-19
32ERROR

The strings/concat4.cmd code block should be strings/concat5.cmd. concat4 is repeated from the previous page, and does not contain the str() function that the text describes.

2011-01-19
35OK

This example shows how the tab character…" I found this slightly unclear on the initial reading, since “this example” seems like it should refer to the example that immediately precedes this text (print5.cmd) and not the example that we are about to see (print_var.cmd). Perhaps "The next example …

2011-01-19
36OK

“Other markers that we might use are %s, to insert a string value, and %d, to insert an integer.” This is a very minor comment, but I think the use of commas after each of the markers is slightly unclear, although it is grammatically correct. It seems like it would be possible to interpret the comma as part of the marker if you have never seen printf before. Perhaps the commas could be deleted (“… are %s to insert a string value, and %d to insert an integer”), or the descriptions could be placed in parenthesis.

2011-01-19
39OK

Q6. Part c) has a single symbol for greater than or equal to, rather than >=. Since this is a Python expression, I believe that it should be the latter.

2011-01-19
49TYPO

modules/main_help.py. Grammatical error in “Return True if the named create is recognized as a dinosaur, and False otherwise”. Perhaps “Returns True if name is recognized…”

2011-01-19
60TYPO

Fig 4.9. Copy/paste error for the description of get_blue(pixel) and get_green(pixel). Both of them read “Gets the red component of pixel”.

2011-01-19
61TYPO

Fig 4.10. Copy/paste error for the description of lighten(color). It’s the same as darken(color).

2011-01-19
62SUGGEST

modules/structure.py. Should this be called “test_temperature.py”?

2011-01-19
63SUGGEST

modules/structure.out. As on p62. Should this be test_temperature.out?

2011-01-19
83ERROR

lists/nested_loops.cmd. Science quibble: Br is not a gas at standard temperature and pressure. Perhaps you could say halogen?

2011-01-19
84OK

“Geneticists describe C. elegans …”. Science quibble: technically, you are supposed to use spell out both the genus and the species (Caenorhabditis elegans) the first time you use an organism name in a document, and then abbreviate it (one letter of the genus, spell out the species; e.g., C. elegans) on subsequent uses. However, C. elegans is probably better known than Caenorhabditis elegans, and since this isn’t a biology text, I don’t think I would bother changing it.

2011-01-19
88OK

Box “Where Did My List Go?”. The outline around lists/colors2.cmd is not visible because the larger box is the same color.

2011-01-19
95TYPO

“… that we have added comments as well as …”. “Comments” should be in italics, not in the “expression” font.

2011-01-19
95SUGGEST

Section “Command-Line Arguments”. Should there be an discussion about how to provide command-line arguments in Wing?

2011-01-19
78OK

isLeap should be isleap
c) Read the description of the function isLeap. Use isLeap to determine the next leap year.

2011-01-19
71OK

I’m not sure why you’re sending readers to python-nose when python has testing built-in. Here’s a sample test_temp.py

import unittest
from test import test_support
from temp_with_doc import to_celsius

class MyTestCase1(unittest.TestCase):

def test_freezing(self):
’‘’Test freezing point.’’’
assert to_celsius(32) == 0

def test_boiling(self):
’‘’Test boiling point.’’’
assert to_celsius(212) == 100

def test_roundoff(self):
’‘’Test that roundoff works.’’’
assert to_celsius(100) == 38 # NOT 37.777…

if name == ‘main’:
test_support.run_unittest(MyTestCase1)

2011-01-19
191ERROR

setdict/countbirds3.py is identical to setdict/countbirds4.py. The former is not supposed to invert the dictionary.

2011-01-19
158TYPO

in tsdl.py and read_smallest.py, the “print line” next to “line = skip_header®.strip()” should be eliminated. Why should you print the first line of the reader r? read_smallest_skip.py in p.160 correctly doesn’t do this.

2011-01-19
158TYPO

Sorry, #42741: was wrong. Only “print line” in read_smallest.py should be eliminated.

2011-01-19
159TYPO

in read_smallest_hebron.cmd, 2 occurrences of process_file should be smallest_value.

2011-01-19
21OK

This error is with regards to the EPUB version of this book. Page 21 causes the Nook to hang. Tried on two Nooks with the same unfortunate result.

2011-01-19(Dave Thomas here: The Nook has a bug, and loops endlessly when a table is wider than its display. We've contacted them, and they don't seem to be interested in fixing it. There's not much we can do there, I'm afraid. It might help if you were to contact them and push the issue, too).
44OK

She said, That’s hard to read.

2011-01-19
89TYPO

The value for Canada’s life expectancy in the list is not the same value illustrated in Figure 5.10.

2011-01-19
198OK

In the searching section, 10.1, it is written that we can find the year that whale sightings bottomed out by using the “index” method of our “counts” list. However, lists are zero-based, so while the book says the sightings were in year 6, the answer should be 7, right?

2011-01-19
58TYPO

Return True if the named create is recognized as a dinosaur, and False otherwise.

Should read
Return True if the named creatURe is recognized as a dinosaur, and False otherwise.

2011-01-19
96ERROR

“As we’ll discuss in Section 4.5, Testing, on page 70, mistakes like
these can quickly be caught by writing and running a few tests.”

“as we disucussed”, no?

2011-01-19
34ERROR

on Mac OS X, it is one ‘\\r’

should read

on Mac OS X, it is one ‘\

OS X uses \
just like other posix systems. Earlier MacOS versions <= 9 used ‘\\r’.

2011-01-19
34TYPO

At the top of the page there are a few examples that are supposed to show the round() function rounding floats to the nearest integer, but the results of each example shows float values.

2011-08-23Added a parenthetical comment about the function's return type.
30TYPO

2.6 Function Basics
“Earlier in this chapter, we converted 80 degrees Fahrenheit to Celsius” - shouldn’t it be 212 degrees Fahrenheit instead of 80 ?

2011-08-23
45TYPO

>>> print “The Latin ‘oryctolagus cuniculus’ means ‘domestic rabbit’.”
The Latin ‘Oryctolagus cuniculus’ means ‘domestic rabbit’.
—> the letter “O” is capitalized in the output of “Oryctolagus”

2011-08-23
131ERROR

for variable in list: block

should not be there?

2011-08-23
51ERROR

Where is the media module you indicated is in a source_code.zip file? That module is missing in that file. (Page 51) I will check back to see if that file is added to the zip file you suggested.

2011-08-23New URL for source code is: http://packages.python.org/PyGraphics/ \n \nContains latest code and installation instructions for Windows and Linux. Mac OS X coming soon.
214ERROR

Figure 11.2: LOGARITHMIC GROWTH contains multiple errors. Row 4’s N value 1,0000 should be 10,000 and row 5’s 10,0000 should be 100,000. Row 6 “100,000 24” should be “1,000,000 20” and row 7 “1,000,000 27” should be “10,000,000 24”

2011-08-23
175TYPO

I believe the footnote to the “more elegant solution” should say that the function “returns a single list per record” instead of “a single tuple per record”. The docstring makes it clear that no tuples are being returned.

2011-08-23Corrected the description of the return types in fileproc/fixed_width_1.py and fileproc/fixed_width_2.py to be list of tuples of tuples and list of tuples, respectively. This is consistent with what the footnote was describing, so no change to the footnote is required.
21TYPO

It seems that the latex symbol \\dagger was used instead of letter ‘t’ twice on page 21 when referring to the parameter of function to_celsius()

2011-08-23Although the 't' does look a little odd, the \\dagger tag isn't actually being used. The format of the 't' in those cases is consistent with the format used throughout.
4535TYPO

It seems that the latex symbol \\dagger is used instead of the letter ‘t’ to indicate the \\t tab character on the paragraph right below example strings/print5.cmd

2011-08-23Although the 't' does look a little odd, the \\dagger tag isn't actually being used. The format of the 't' in those cases is consistent with the format used throughout.
122142TYPO

The chemical formula for methane in example cond/elif_longer.cmd seems incorrect. It should be CH4, not CH3.

2011-08-23
77TYPO

Third line from the bottom:
> You can manipulate images using the picture module,

picture —> media

2011-10-14
75TYPO

In the v4.0 PDF and mobi version, the first example after the first paragraph in section 5.4 appears like this:

for variable in list:
block

where the formatting tags did not work as intended (as compared to my v2.0 PDF where the text is actually shown in bold.

This error seems consistent throughout the entire book, not just this one example. A text search for ‘’ will likely reveal a number of such problems.

19TYPO

tags visible

204ERROR

In the first if statement you have:

else:
min2, min1 = 1,0

That should be

else:
min2, min1 = 0,1

9ERROR

17 / 10 produces 1.7 not 1 (an integer).
Int division would be 17 // 10 and produce a one.
Perhaps the text is not current with now state of Python.

102TYPO

For some of the pages when they try to explain new terminologies, I see a bunch of blotchy text format code like this one from page 102

condition:
block

98TYPO

Q 7 says to print half_lives in 5.5 Slicing pg 84 when half_lives is in 5.3 Built-in Functions on Lists on pg 79

176TYPO

The code for inverting a dictionary appears on page 176, right before the inverting a dictionary section, and then again on page 177 (exact same code) in the inverting a dictionary section.

91TYPO

“another fundamental concepts” should be “another fundamental concept”

100TYPO

tags are visible at the beginning of section 6.2 (as they are in a number of places in the book)

890ERROR

Since I’m a beginner, I’m sure this is my error; however, I’m running Wing IDE (as suggested in the class resource area and on PDF Loc 890 where the “What happens During Import” area is.. I get an error when tring to import experiment .. import experiment
Traceback (most recent call last):
File “”, line 1, in
Syntax Error: print “The panda\\‘s scientific name is ’Ailuropoda melanoleuca’”: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/experiment.py, line 164

Here are the contents of experiment.pyprint “The panda\\‘s scientific name is ’Ailuropoda melanoleuca’”

77ERROR

I downloaded the lists/multiplication_table.py from the provided link.
When inserted into a blank file or run through the Python visualizer you get the following error:
Error: invalid syntax (, line 6)

78ERROR

In the box “Where did my list go”, the variable colors is assigned ‘red orange yellow green blue purple’.split().
Then, colors is evaluated, and suddenly the list is sorted, even though the .sort() method isn’t performed until on the following line.

1-endTYPO

There appears to be a typo in the CSS of the epub edition.
It says “.example\t Property padding-rightt doesn’t exist : 1em” Search for “rightt” in the css code. Using Flightcrew (epub checker generated 7 errors). Using ShuBook on ipod touch generates an error code “f_00xx.html, In init” where xx is the page number. While iBooks Kobo and FBReader opens it OK, Bluefire and ShuBook fails to do so

43ERROR

on def to_celcius(t):
return(t-32)*5.0/9.0

Traceback (most recent call last):
File “”, line 2, in
IndentationError: expected an indented block (, line 2)
Using wing
using python on Terminal same error message

112TYPO

In the first sentence, “…the empty list [] all are considered to false,…” should be “…the empty list [] all are considered to be False,…”

125TYPO

Markup tags appear instead of formatted text: “for variable in list:”. “list” should be printed in bold.

122115SUGGEST

Page 114 (probably blank) is missing

115ERROR

methane molecular formula = CH4 not ch3.

for page 115, 116, 142 too similarly.

337TYPO

in the code for db/db_distinct.cmd
“DISTINCT” is missing.

should be: SELECT DISTINCT PopByRegion.Region
FROM …

Categories: