The Web Page of the Book of the Web page |
Despite being reviewed multiple times and being read after copyediting, typesetting and proof-reading I'm sorry to say that a lot of errors have slipped through the net. Mostly they are typos and layout errors which should be fairly obvious how to fix. Unfortunately there are a few more serious mistakes. I've listed them all here and will try to get them fixed in any subsequent print runs. If anyone spots any other errors then please let me know via the feedback page.
One note on the descriptions on this page. I try to identify the locations as clearly as I can, normally when referring to paragraph N I do NOT count code segments as paragraphs. Apparently there are a few cases when I've not followed my own rules consistently, apologies and I'll fix it as soon as I can.
Location | Correction |
---|---|
Page 7, 2nd last line | delete"and some ideas for projects". The projects were removed from the Annex following a reviewers comments that they were not "resources"... |
Page 19, last line, first paragraph. | Typo: insert comma after "source code" |
Page 32, sidebar. | Typo: last three examples are all missing a "%" sign before the codes.
eg. the last example should read: >>> print "%9.2f" % 123.456 |
Page 35, line 3, first paragraph. | Typo: delete quotes around washes |
Page 50, line 4, paragraph 4. | Typo: "data type" should read "date type" |
Page 50, last line, paragraph 4. | add "which is covered in Chapter 11." to the end. |
Page 51, Address discussion | Several readers had problems understanding this in the web tutor. I have created an expanded explanation here(CA) |
Page 51, line 2, paragraph 4. | "fields" is a new term so should be in italics |
Page 51, line 3, paragraph 4. | Typo: "acheived" should be "achieved" |
Page 52, 2nd line of code | comment spills onto next line - keep on a single line |
Page 53, paragraph 3 | Typesetting error: paragraph needs reformatting |
Page 57, last code section | This is the worst error so far, a whole section of code has
gone missing! At the end of the page add the following lines:# get B's dimensions lenB = totalLength - (lenA + lenC) widthB = longA - shortA # Now calculate areas of A and C A = lenA * longA C = lenC * widthC In fact there is a clue in the text since it says the program is 18 lines long but in fact there are only 12 lines shown! |
Page 71, Sidebar, 1st line of code | Typo: delete "{" at end of line |
Page 75, last line. | Change last sentence to: "Several of the resources listed in Appendix C include GUI tutorials" |
Page 83, 1st line | Clarification: insert " list or" before "tuple" |
Page 83, factors function | Formatting: body of function should be in bold face |
Page 107, footnote 3, line 2 | Typo: replace "whichever" with "the" |
Page 108, Second code block, lines 1,2 | Formatting: Keep bold face but remove italics |
Page 123, 1st paragraph, last line | Typo: change "is" to "in" |
Page 128, 1st paragraph, line 3 | Typo: change "Yourdan" to "Yourdon" |
Page 138, 2nd paragraph, line 6 | Clarification: change "subroutines" to "functions" |
Page 139, 1st code segment | Typesetting: "def doKeyEvent(key):" should not be after the event loop. Python needs to see the definition of a function before it can call it, therefore move both event handling functions above the while 1: line and comment on page 138. Also note that this example does not run correctly within IDLE, you must run it from a DOS prompt. Thanks to Britt Green for pointing this out. |
Page 139, 1st code segment, line 2 | Typesetting: "def doKeyEvent(key):" should not be boldface |
Page 145, paragraph 1, line 2 | Clarification: Change "sentence" to "line" |
Page 164, tip #4, last line | Typo: Change "...of to len()-1" to "..of up to len()-1" |
Page 167, Paragraph 1, line 2 | Correction: Delete sentence "Appendix C contains...yourself" |
Page 171, Footnote 2, line 1 | Typo: Change "interation" to "interaction" |
Page 185, Note 3, line 3,4 | Typo: Delete "there are" |
Page 188, Code, import line | Typo: add , re after string |
Page 191, getWords() function | Error: The CD ROM source code is generally better for this case
study but doesn't match the text exactly. This particular function
however, is better written as:def getWords(self): for i in range(len(self.groups)): self.groups[i] = self.ltrim(self.groups[i]) self.groups[i] = self.rtrim(self.groups[i]) self.removeExceptions() This change ensures that we overwrite the character group rather than attempting to change it in situ - which should theoretically be impossible since strings are immutable. It is only a foible of Python's accomodating nature that lets us get away with the original code! |
Page 192, Last paragraph line 2 | Typo: "< or >" shoulb be "< and >" |
Page 192, Last paragraph line 3 | Typo: getWords becomes getCharGroups |
Page 192, Last paragraph, last line | Typo: delete trim |
Page 193, class HTMLDocument | Typo: This code is faulty - it uses self.lines which
does not exist! If you look at the code on the CD you will
see why its been done that way. A better solution all round
is to change the class definition to look like this:
class HTMLDocument(TextDocument): def getCharGroups(self): tag = re.compile("<.+?>") para = re.compile("<[pP]>") # identify paragraph tags self.para_count = 0 # using <p>'s not empty lines f = open(self.filename,"r") # should use try/except lines = f.readlines() n = 0 while n < len(lines): if len(lines[n]) > 1: # if its not blank if para.search(lines[n]): # its a paragraph self.para_count = self.para_count + 1 lines[n] = tag.sub('',lines[n]) # lose tags if len(lines[n]) <= 1: # empty or '\n' left del(lines[n]) else: self.groups=self.groups+string.split(lines[n]) n = n + 1 else: n = n + 1 self.line_count = len(lines) This is a big change but has the advantage that we can reuse all of the other TextDocument methods without change. |
Page 194, printStats method, 2nd statement | Typesetting error: used:" should be on same line as the print statement above |
Page 207, line 3 | Typo: Change "is" to "in" |
Page 207, 2nd last paragraph, line 1 | Typo: Game should NOT be in bold face |
Page 208, Paragraph 1, line 1 | Typo: Guess should NOT be in bold face |
Page 208, Paragraph 3, line 3 | Typo: Game should NOT be in bold face |
Page 208, __init__ method of Game class, line 3 | Typo: Comment should be in bold face |
Page 212, Paragraph 3, line 7 | Typo: delete "new" - we already created it in the abstract Target class |
Page 213, getResult function, 5th last line | Typo: remove parens around c in guessed |
Page 214, 1st two paragraphs | Typo: play, Game and Guess should NOT be in bold face |
Page 214, 2nd last line | align index = ... with other lines in block, and
use line continuation chacter '\', thus:
wrdFile.close() index = int( whrandom.random() * \ (len(wordList) - 1) ) self.goal = wordList[index][:-1] # lose \n |
Page 215, 3rd line | Typesetting error: align with line above |
Page 216, line 7 | Typo: delete 's' at end of "programs" |
Page 218, lines 4,5,13 | Typo: Replace "lives" with "outcome". I originally used lives but decided outcome was a more generic name for the abstract framework we were creating |
Page 218, line after # update image | typesetting problem: '.gif' should be part of the line above. Use line continuation to tidy up: theFile = self.imgpath + 'hm' + \ str(self.outcome) + '.gif' |
Page 219, line 2 | Typo: Replace "lives" with "outcome" as above |
Page 220, Line 8,11,12 | Typesetting error: align options under arguments to widget
constructor. For example:
c = Frame(self, border=1, relief=RAISED, background='blue') |
Page 222, paragraph 2, last line | Typo: insert "which" before "must" |
Page 222, paragraph 4, line 4 | Typo: delete 'as' |
Page 223, paragraph 1, line 1 | Typo: make 'thinks' singular |
Page 227, Last 2 lines. | Typo: Delete "and...investigation" |
Page 232, line 3 | Make "Web" all lowercase |
Page 239, line 8 | Typo: insert space between 'm' and '=' |
The above errors have been reported to Addison Wesley and are fixed in the second printing. The only exceptions are the errors on Page 71, page 139(first error), page 192(2nd and 3rd errors). A few others have not been corrected completely but the good news is that there are no more errors that actually prevent code working from the list above. You can tell whether you have a second print by looking at the bottom of the page facing the dedication.
The following errors have been found after my post production review, where reported by a reader credit is given in parens:
Location | Correction |
---|---|
Page 33, second paragraph, 3rd line | Typo: "because is is a" should be "because it is a" (CA) |
Page 57, 1st code segment, 1st line | Typo: "Radius" should be "Area" (AW) |
Page 58, 1st paragraph, 5th line | Typo: "top 5 lines" should be "top 6 lines" (CA) |
Page 70, second code example | Typo: add a colon(:) after 'else' (CA) |
Page 70, last paragraph | Error: This says that we should put the largest valued test first
but in fact that won't work either, since the >10 line will then
not be executed! Instead to do this kind of check you need to miss
out the 'else's completely and just have a series of if tests like so:
val = 100 if val > 10: print 'OK' if val > 50: print 'OK too' if val > 100: print 'not this time' Where you would use if/elif is where you want to select the first valid choice out of several, in which case the book's warning is correct. Start high and work down to the lowest value. If the tests were for 'less than' of course you would start at the lowest value: val = 100 if val < 10: print 'Low' elif val < 50: print 'Higher' elif val < 100: print 'higher still' else: print 'too high for me!'(CA) |
Page 74&75, Command-Line Values Section | Clarification: The code for this section will not work from
the interactive python prompt you must enter it into a script
file(say args.py) and run it from an operating system command prompt.
To see any parameters being printed you must provide some, thus:
C:PYTHON\PROJECTS> python args.py 7 23 spam args.py 7 23 spam the first real argument was: 1 Note that if using Pythonwin you can enter areguments in the Run dialog that pops up after you hit the Run button. IDLE does not provide this facility so you must use the OS prompt as shown above. |
Page 78, 2nd code example (first using string.split), last line | Error: replace words = with print. Otherwise you don't see the result! |
Page 93, Sidebar | Clarification: Add >>> import struct before second code segment |
Page 82, line before last code segment | Typo: "us" should be "use" |
Page 118, 2nd code segment, 2nd line | Typo: import printlist should be should be import printList (CA) |
Page 124, last line | Error: "print function" is incorrect. print is technically a command not a function and thus has a different lookup mechanism. To be correct the example segment should look like this:if Z > W: # pow function comes from builtin namespace print pow(Z,W) ...etc...(JE) |
Page 125, 3rd paragraph, 2nd line | Typo: "modul." should be "module." (CA) |
Page 138, Code listing | This code will not run correctly under Pythonwin, it seems to cause an infinite loop displaying 255. The solution is to save the file and run it from a DOS prompt. (BR) |
Page 138, event loop code block, line 6 | Layout: This line should be indented under the if (key == '\000')... line. [Its purpose is to ignore the dummy prefix character on special keys(F10 etc) and read the real value] (BR) |
Page 158, 1st PDB listing, line 5 | Layout: The return in line 5 should be indented like line 3 (AW) |
Page 158, 1st PDB listing, line 8 | Layout: The 'from' should be aligned with the 'if' in line 9 (AW) |
Page 159, sidebar, last line | Typo: "more effective that..." should be "more effective than..." (CA) |
Page 192 | Ommission: The reportStats method is not shown. This is not a huge problem because we rewrite it on page 194 anyway so use the code there instead. Sorry about that! |
Page 194, generateStats function, line 4 | Error: sentence_count should be self.sentence_count (CA) |
Page 213, __init__() function, 2nd line | Typo: guessType should be GuessType |
Page 220, 3rd last line | Typo: delete colon immediately after 'lambda' |
Page 241, Perl, Line 2 | Mistake: Pathetically -> Pathalogically (MC) |
Page 242, Message class definition | Mistake: $self should be defined outside the methods,
otherwise it is a local variable to the method. Thus package
should look like:
package Message; my $self = {}; sub new { my $class = shift; $self->{txt} = shift; bless ($self, $class); return $self; } sub print { if ($self->{txt} eq "") { print "No message"; } else { for ($i = 0; $i < 3; $i++) { print $self->{txt}, "\n"; } } } 1; (MC) |
Page 242, print subroutine, 2nd print statement | Typo: missing semi-colon at end of line, see above for correction(MC) |
Page 242, hello.pl, 2nd line | Stylistic error: $m = ... should be:
my $m = ... It works as is but Perl stylists prefer to have the my.(MC) |
Page 245, Lisp, 2nd Line | Typo: McArthy -> McCarthy(MC) |
The following people spotted mistakes and reported them. Many thanks to:
You can contact me by regular email at:
alan.gauld@btinternet.com