Errata for Learning Python

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page xiv

Anonymous    May 01, 2000
Printed
Page xvi
1st paragraph

"Geoff Philbric" now reads "Geoffrey Philbrick" "Hibbitt, Karlson & Sorenson" now reads "Hibbitt, Karlsson & Sorenson, Inc."

Anonymous    May 01, 2000
Printed
Page 31
Table 2-3

Anonymous    May 01, 2000
Printed
Page 33
1st paragraph, last sentence

After "expressions;" the sentence was changed to read: "...variables are replaced with their values, and expression results are echoed back to us:"

Anonymous    Sep 01, 2000
Printed
Page 45
Table 2-7, 2nd column, 3rd item

now reads: Four items: indexes 0..3

Anonymous    Jan 01, 2001
Printed
Page 76
In "a...b," the "..." was put in regular type.

Anonymous    Sep 01, 2000
Printed
Page 78
All instances of "..." were put into regular type (4 times).

Anonymous    Sep 01, 2000
Printed
Page 87
3rd paragraph, the code example

Mathematically, integers less than 2 are NOT considered prime. Hence, the else statement after the while loop will still print y as prime even if y contains values such as 0 or 1, which are NOT prime! So instead of ... else: pirnt y, 'is prime' It should really be ... else: if x == 1: pirnt y, 'is prime' This is a bug in what the code is supposed to achieve. AUTHOR: Yes, this is true; but I don't think it's worth patching (we'd also then have to explain this odd new test in more details in the text, and it would distract from the point of the example). However, I will add a note in the 2nd Edition about this. This little code snippet demos a Python while loop, and doesn't claim to be a mathematically precise definition of prime. It's also wildly inefficient, but doesn't aim to address better algorithms either.

Anonymous
Printed
Page 88
In "... print X," the "..." was put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 89
All instances of "..." were put into regular type (8 times).

Anonymous    Sep 01, 2000
Printed
Page 90
All instances of "..." were put into regular type (8 times).

Anonymous    Sep 01, 2000
Printed
Page 105
4th line of code

"..." was put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 106
2nd line

"that exist when the function is called." now reads: "that exist immediately after the function is called."

Anonymous    May 01, 2000
Printed
Page 107
5th line of code

"..." was put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 108
Last paragraph, last sentence

"assigns toast and eggs" now reads: "assigns toast and ham"

Anonymous    Jan 01, 2000
Printed
Page 117
1st block of code, line 4

"..." was put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 118
5th line of code

"..." was put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 119
6th block of code

"..." was put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 120
1st block of code, 7th line and 2nd block of code, 5th line

Both "..." were put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 121
3rd line of code

"..." was put into regular type.

Anonymous    Sep 01, 2000
Printed
Page 132
bottom paragraph, first line

"Just like def, import, and from are executable statements,..." now reads: "Just like def, import and from are executable statements,..."

Anonymous    May 01, 2000
Printed
Page 139

(139) to the entry for "sys.path" immediately above.

Anonymous    Jan 01, 2000
Printed
Page 142
4th line in the "listing" function

"module.___name__" now reads "module.__name__" (two underscores, not three).

Anonymous    Sep 01, 2000
Printed
Page 148
Table 5-1, row 3, column 1

"from mod import" now reads "from mod import *" (added the star)

Anonymous    Jan 01, 2000
Printed
Page 149
1st line

Anonymous    Jan 01, 2000
Printed
Page 153
end of comment in example in mid page:

In "# self is the instance", last 2 letters no longer in bold type.

Anonymous    Jan 01, 2000
Printed
Page 177
paragraph 2, sentence 2:

"...in each class that it lists in its header line." now reads: "...for each class that includes Lister in its header line."

Anonymous    Jan 01, 2000
Printed
Page 202
second paragraph

In "Catching 1-of-N Exceptions," "It inspects expect clauses..." "expect" now reads "except".

Anonymous    Sep 01, 2000
Printed
Page 205
Code near end of "Why You Will Care" box

changed: def dostuff(); ... doLastThing(); to: def doStuff(): ... doLastThing() Last paragraph, 1st sentence: "there's no ned" now reads "there's no need"

Anonymous    Jan 01, 2000
Printed
Page 216
code section, 9th line

"dir (sys)" after the prompt (">>>") is now in bold.

Anonymous    Sep 01, 2000
Printed
Page 219
3rd paragraph, 1st sentence;

The order of cmp return value interpretations wass wrong here. It has been changed to: The cmp built-in returns a negative integer, 0, or a positive integer, depending on whether its first argument is less than, equal to, or greater than the second one.

Anonymous    Aug 01, 2001
Printed
Page 220
Entry for "tuple(seq)" now reads "Returns the tuple version..."

Example of ord(c) now shows ord('A') value as 65.

Anonymous    Jan 01, 2000
Printed
Page 221
Table 8-2

The description for the "setattr" built-in function was added: setattr(object, attributename, value) -> Assigns value to attribute attributename of object; raises TypeError if not supported; creates of changes attribute.

Anonymous    Sep 01, 2000
Printed
Page 224
3rd line

"a callable objects" now reads "a callable object"

Anonymous    May 01, 2000
Printed
Page 227
under "Regular Expressions:"

"The character * means ..." now reads "The character + means ..."

Anonymous    Jan 01, 2000
Printed
Page 231
"Most Frequently Used Functions from the os Module" chart, last two

Anonymous    Sep 01, 2000
Printed
Page 234

os.path.walk('..', test_walk, 'show' now reads: os.path.walk('..', test_walk, 'show')

Anonymous    Jan 01, 2000
Printed
Page 236
Table 8-11, last line under "Behavior"

Last line is now indented properly.

Anonymous    Sep 01, 2000
Printed
Page 236
Table 8-12, 5th line under "Behavior"

This line is now indented properly.

Anonymous    Sep 01, 2000
Printed
Page 240
code section at beginning

After the prompt ("(Pdb)") lines 2, 3, 5 and 8 are now in bold.

Anonymous    Sep 01, 2000
Printed
Page 240
Second half of page, code block

The "*" was removed from the do_timing function's def header. Also, a "," was added to the print statement at the end of do_timing. The code now reads: import time, makezeros def do_timing(num_times, funcs): totals = {} for func in funcs: totals[func] = 0.0 for x in range(num_times): for func in funcs: starttime = time.time() # record starting time apply(func) stoptime = time.time() # record ending time elapsed = stoptime-starttime # difference yields time elapsed totals[func] = totals[func] + elapsed for func in funcs: print "Running %s %d times took %.3f seconds" % (func.__name__, num_times, totals[func]) do_timing(100, (makezeros.lots_of_appends, makezeros.one_multiply))

Anonymous    Aug 01, 2001
Printed
Page 253
2nd line from top

Anonymous    Jan 01, 2000
Printed
Page 255
2nd line from bottom:

"a lists of lists" now reads "a list of lists"

Anonymous    May 01, 2000
Printed
Page 257
2nd paragraph from bottom, line 3

"are just as fast" now reads "are probably faster."

Anonymous    Jan 01, 2000
Printed
Page 258
Last paragraph, 1st word

"Using" is now in normal font.

Anonymous    Jan 01, 2000
Printed
Page 259
in example at top

os.system('/usr/bin/mail ... < %(tempfile)s' ... ) now reads: os.system('/usr/bin/mail ... < %(tempfilename)s' ... )

Anonymous    Jan 01, 2000
Printed
Page 261
Last paragraph, 2nd line from bottom

"text from the string str" now reads: "text from the StringIO object str"

Anonymous    Jan 01, 2000
Printed
Page 265
In the get_temperature(country,state,city) function,

line 13 used to read: stop = string.index(data,'&degv;F',start-1) It now reads: stop = string.index(data,'&deg;F',start-1)

Anonymous    Jun 01, 1999
Printed
Page 278
code section for class FormData

"def __init__(self, formdict)" now reads "def __init__(self, form)"

Anonymous    Jan 01, 2000
Printed
Page 281
Deleted space between "FormData." and "__init__" in second text

paragraph.

Anonymous    Jan 01, 2000
Printed
Page 288
code near bottom

from tkinter import mainloop now reads: from Tkinter import mainloop

Anonymous    Jan 01, 2000
Printed
Page 290
code at top

added line: self.listbox.bind('<ButtonRelease-1>', self.select) after line 6.

Anonymous    Jan 01, 2000
Printed
Page 292
beginning of last paragraph

Anonymous    Jan 01, 2000
Printed
Page 293
extra paren in program code near top of page

string.replace(labelstr, ' '), '') now reads: string.replace(labelstr, ' ', '')

Anonymous    Jan 01, 2000
Printed
Page 294
third paragraph from bottom

The URL for JPython now reads "http://www.jpython.org/".

Anonymous    Sep 01, 2000
Printed
Page 295
middle of page

The URL for JPython/CPython differences now reads "http://www.jpython.org/ docs/differences.html".

Anonymous    Sep 01, 2000
Printed
Page 296
5th line of code

added a single quote before "This"

Anonymous    Jan 01, 2000
Printed
Page 325
1st paragraph, last line

"Conifg" now reads "Config" Last column of last row of table B-1: Changed the contact point for the maintainer of the Python port on VxWorks, Jeff Stearns, to read "mailto:jeffstearns@home.com"

Anonymous    Jan 01, 2000
Printed
Page 330
1st paragraph, line 5

"...L[3:3], the empty insertion point after offset 3" should really be "...L[3:3], the empty insertion point before offset 3" Note it is "before", not "after" AUTHOR: Yes: this is incorrect wording. It should read "at offset 2", not "after offset 3". "Before" doesn't really work here nay more than "after".

Anonymous
Printed
Page 352
end of solution 4:

used to read: def word(self, index): return self.words[index] now reads: def word(self, index): return self.words[index] # properly indented!

Anonymous    Jan 01, 2000
Printed
Page 356
solution #2:

used to read: print "Got comment from %(name)s, skipping printing." % vars(data) now reads: print "Got comment from %(name)s, skipping printing." % vars(data) solution #3: used to read: # code from existing program, up to graphics.fillPolygon(xs, ys, len(xs)) now reads: (left aligned!) # code from existing program, up to graphics.fillPolygon(xs, ys, len(xs))

Anonymous    Jan 01, 2000
Printed
Page 365
index:

Deleted the "sys.path dictionary" entry and added its page number

Anonymous    Jan 01, 2000