The errata list is a list of errors and their corrections that were found after the product was released.
The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.
| Version |
Location |
Description |
Submitted By |
| Safari Books Online |
Chp 5.2
14th row in Table 5-2 |
The "bitwise complement" operator is incorrectly represented by an odd symbol (http://safari.oreilly.com/images/ent/U02DC.GIF, a circle with a tilde on top) rather than a simple tilde (~).
|
Anonymous |
| Safari Books Online |
most pages
most code samples |
All double underscores are incorrectly separated by a space character.
e.g., The method name "__init__" is displayed as "_ _init_ _".
|
Anonymous |
| Safari Books Online |
Chp 7.1
Table 7-2 |
The "Octal digits value" entry in the table is incorrectly listed as "\ooo" when it should be "\000"
|
Anonymous |
| Safari Books Online |
3
second fixed-width section |
The output of the "print 2 ** 100" statement is incorrectly appended with the letters "km"
|
Anonymous |
| Printed |
Page 24
Second code example |
The letters "km" after the number should be removed.
|
Anonymous |
| Printed |
Page 49
Last heading |
the first word of the title, "import", is in lower case.
|
Anonymous |
| Printed |
Page 79
3rd line from the bottom |
D['quantity'] += 1
should be
D['quantity'] + 1
|
Anonymous |
| Printed |
Page 101
page 101 |
This is an excellent book. Very easy to follow and learn from. Thanks!
I discovered an errata on page 101 that does not appear to be documented yet:
>>> "%e" % num
'3.333333e-001'
...should be...
>>> "%e" % num
'3.333333e-01'
There is an extra zero in the exponent in the book.
|
Anonymous |
| Printed |
Page 107
5th paragraph |
The paragraph reads "Printing the result to produce the user-friendly display format doesn't completely help, either because the hardware related to floating-point math is inherently limited in terms of accuracy:"
I believe the comma is misplaced, and should be at "...doesn't completely help either, because the hardware..."
|
Anonymous |
| Printed |
Page 108
2nd and 3rd examples |
I found that I couldn't execute the second and third examples on the page until I executed "import decimal".
|
Gary Roth |
| Printed |
Page 109
footnote |
The footnote on this page is almost identical to the first paragraph after the "Booleans" header -- it seems redundant.
|
Anonymous |
| Printed |
Page 113
Bottom |
The word "repetition" has been misspelled as "repitition".
|
Anonymous |
| Printed |
Page 142
Top of page beginning with >> reply = |
Forget my submission: I forgot the trailing "s" when I entered %(name)s (Guess this must be like cprintf("%s"),name;) Live and learn if you live long enough
|
Anonymous |
| Printed |
Page 143
Top of page beginning with >> reply = |
3rd Edition: When I try just part of the example I get
reply = """
... Hello %(name)!
... Goodbye"""
>>> values = {'name': 'joe'}
>>> print reply % (values)
Traceback (innermost last):
File "<stdin>", line 1, in <module>
ValueError: unsupported format character '!' (0x21) at index 14
Where's the ! character?? Index 14 appears to be a space
|
Anonymous |
| Printed |
Page 146
4th paragraph example |
The example states:
>>> 'SPAM'.join(['eggs', 'sausage', 'ham', 'toast'])
'eggsSPAMsausaugeSPAMhamSPAMtoast'
I believe this should be:
'eggsSPAMsausaugeSPAMhamSPAMtoastSPAM'
|
Anonymous |
| Printed |
Page 161
Table 8-2 |
(3rd edition)
The table shows dict.fromvalues(['a', 'b']) as an alternative dictionary construction technique, but
there is no such method as "fromvalues" for the dictionary object.
Page 170 shows dict.fromkeys(['a', 'b'], 0), which is valid and probably what belongs in the table.
|
Anonymous |
| Printed |
Page 171
Quiz Answers 2. |
1) In the text:
or a series of assignments like D = [], D['a'] = 0, D['b'] = 0
"D = []" should be "D = {}"
2) The last sentence of this paragraph, "because all the keys are the same", should be "because all the
values are the same".
|
Anonymous |
| Printed |
Page 177
Table 9-2 |
In the Operation column; the second last row says outout.flush(). It won't work it needs to be
output.flush()
|
Anonymous |
| Printed |
Page 187
4th paragraph (beginning "Here, we should...") and associated code |
Python caching of string objects is not optimized solely on the basis of string length, but also factor in string composition, and thus the code examples can lead to the wrong conclusion.
As an example, if you execute the following interactively:
>>> s1 = 'a b'
>>> s2 = 'a b'
>>> s1 == s2, s1 is s2
(True, False)
>>> s1 = 'asdfasdfasdfasdfasdfasdfasdfasdf'
>>> s2 = 'asdfasdfasdfasdfasdfasdfasdfasdf'
>>> s1 == s2, s1 is s2
(True, True)
In this case 3-character strings are stored in separate objects. However 32-character strings are cached with references to the same object. The difference lies in the embedded whitespace, which separates 'words' in a classical string sense.
Now consider the following:
>>> s1 = 'a,b'
>>> s2 = 'a,b'
>>> s1 == s2, s1 is s2
(True, False)
>>> s1 = 'a1b'
>>> s2 = 'a1b'
>>> s1 == s2, s1 is s2
(True, True)
This behavior indicates that one-word alpha-numeric strings are processed and cached, but that whitespace/special-character containing strings are not cached to the same object.
In practical terms this might affect the fledgling coder's approach, as he/she might assume that the "short" repetitious strings common to multiple objects, such as database records, could be instantiated hundreds at a time without growing the number of objects, only references. In fact that is not true if these "short strings" are not one-word alphanumeric.
A bit of nuance, but I think it is an interesting note for those interested in the implementation of Python as a language, and could be important for those who conduct large-scale textual data-mining using Python as a bed.
|
Anonymous |
| Printed |
Page 190
Figure 9-3 |
The type "Set" is listed as a number type in figure 9-3, while
the correct is that it is a collection type. At least that
is what it says on page 108 (in the same book).
|
Anonymous |
| Printed |
Page 212
First paragraph/example |
The Python 2.5 and 2.6 interpreters don't like the print statement outside the while loop. I get the following error at runtime:
while True:
reply=raw_input('Enter text:')
if reply=='stop': break
print int(reply)**2
print 'Bye'
^
sytax error:invalid syntax
The error is fixed by putting the print statement inside the loop:
if reply=='stop': print 'Bye'; break
This is also the case for the examples on pages 213 and 214.
|
Anonymous |
| Printed |
Page 213
3rd paragraph example code |
The following example is missing the Bye statement after the stop input is made:
Enter text:5
25
Enter text:xyz
Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!
Enter text: 10
100
Enter text:stop
|
Anonymous |
| Printed |
Page 220
example at bottom of page |
First line should read
def knights(name)
Fourth line should read
return action(name)
|
Anonymous |
| Printed |
Page 222
5 |
The book states that:
[T]he expression ((a and b) or c) is roughly equivalent to:
if a:
b
else:
c
However, plugging in values a=1, b=0, and c=1 will give different answers for the two logical statements:
((1 and 0) or 1) evaluates to 1, while
if 1:
0
else:
1
evaluates to 0.
|
Anonymous |
| Printed |
Page 233
4th paragraph |
In the paragraph that starts "This works because..." there is a typo in the name of the stream:
"sys.sytdout" should be "sys.stdout".
|
Anonymous |
| Printed |
Page 259
In the Why You Will Care: File Scanners box |
In the Why You Will Care: File Scanners box, second to last code example,
xreadlines() is presented as an option. According to the Python Library
Reference, xreadlines() is "...Deprecated since release 2.3. Use "for line
in file" instead."
http://docs.python.org/lib/bltin-file-objects.html
|
Anonymous |
| Printed |
Page 283
1st paragraph |
The user typed command
">>> print open.__doc__"
does not match with the printed output
"file(name[, mode[, bhuffering]]) -> file object".
The correct user typed command has to be instead
">>> print file.__doc__"
|
Anonymous |
| Printed |
Page 293
1st paragraph, 3rd line |
"We met doctrings, explored the online and manual resources..."
The word "doctrings" is mistyped. The correct spelling should be "docstrings".
Book edition: 2008 reprint
|
Weakish Jiang |
| Printed |
Page 326
5th paragraph, 2nd line |
"Argument names in the function become new, local names..."
should be
"Argument names in the function become new local names..."
The comma is unnecessary.
|
Weakish Jiang |
| Printed |
Page 329
1st paragraph |
3rd line is "our programs with"...
should be "our programs without"...
|
Anonymous |
| Printed |
Page 347
6th paragraph, 2nd line |
sys.stdout.write(str(x)+'nī)
Note: the last single quote is misprinted.
|
Weakish Jiang |
| Printed |
Page 355
bottom output lines |
bottom output sequence is not what i got from python version 2.5.1
on a Solaris ultra 45 using OS 5.10
i got data1 then data3 than data2
it should be (i think) 3,2,1 as shown in book
this implies that the order in which classes are accessed
is not from bottom all the way up starting from left to right
ie, python implementation is wrong
|
Anonymous |
| Printed |
Page 462
Beginning of 2nd paragraph |
The word awhile exists, but it is an adverb. So, "a while" should be used instead.
|
Anonymous |
| Printed |
Page 463
quiz 2. |
"top to bottom" should be "bottom to top"
|
Anonymous |
| Printed |
Page 471
2nd paragraph |
from "For instance..." to "For example..."
instance is an object created...
|
Anonymous |
| Printed |
Page 525
streams.py code example |
In order for interactive example at top of page 526 to work, the line "self.writer.close()" should be inserted after "self.writer.write(data)" but indented the same as "while 1:". Unlike sys.stdout, a data file must be closed for data to be finally saved to it (that is, so it can be recalled later as in "type spamup.txt" on page 526).
|
Anonymous |
| Printed |
Page 525
(see my prior error submission) |
This is in addition to prior message:
After submitting error, I tried to be sure everything still worked. The converters.py still worked running standalone. The example at the top of page 526 worked this time, with actual output to "type spamup.txt" (actually my command was "cat spamup.txt" in Linux). However the second interactive example on page 526 didn't work this time. After the output "<PRE>SPAM</PRE>", etc., the was an error: AttributeError: HTMLize instance has no attribute 'close'. So whether .py files or interactive examples will have to be modified to achieve total lack of errors, I will try to see if I can suggest anything in keeping with the simplicity of your examples. Thanks for bearing with someone trying to help.
|
Anonymous |
| Printed |
Page 525
(see my first two submissions) |
Continuing from my prior submissions:
In order for the second interactive example in page 526 to work, after including my suggest addition to streams.py, try adding an interactive entry below "print '<PRE>%s</PRE>' % line[:-1]" in class HTMLize. Indented the same as the first "def" try: "def close(self): pass". As crude as this is, it will include "close" in the namespace of class HTMLize, and thus eliminate the error, hopefully without introducing any new ones. I hope these three errata submissions together will help you and your other readers in some way. Thanks for bearing with me.
|
Anonymous |
| Printed |
Page 540
last line of class code |
(3rd Edition)
This isn't an error at all:
return 'Set:' + `self.data`
But backticks aren't covered at all previous to this page (I don't think so, anyway). It was a good opportunity to go on the web to learn that it is the same as:
repr(self.data)
I suspect this is left over from previous editions of the book and that repr(self.data) would be the more modern technique intended. (Which is exactly what is mentioned in the preface to "Programming Python": that `backticks` have been replaced with repr().
|
Anonymous |
| Printed |
Page 540
in the code example, 2nd line |
This line:
def __init__(self, value = []):
should be formatted as
def __init__(self, value=[]):
according to both PEP 8 and the convention of the previous chapters.
|
Weakish Jiang |
| Printed |
Page 542
in the code example, 2nd line |
This line:
def __init__(self, value = []):
should be formatted as
def __init__(self, value=[]):
according to both PEP 8 and the convention of the previous chapters.
|
Weakish Jiang |
| Printed |
Page 583
Code sample, 5th line |
"except IndexError"
which is missing a colon, should be
"except IndexError:"
|
Mark Ture |
| Printed |
Page 674
Line before answer to question 4 |
The last line in the code sample has a typo. Instead of
print 'Got', sys.exc_info(){0], ....
it should say
print 'Got', sys.exc_info()[0], ....
|
Anonymous |
| Other Digital Version |
15921
Chapter header |
(mobi version on Kindle) it may be other places as well- I started on Chapter 25 and there are boxes with question marks on either side of the "25". There are similar marks in the fist sentence, where there is a dash (I guess an M-dash) between "design issues" and "i.e." Similar marks are throughout chapter 25. I looked briefly at chapter 1 - it doesn't seem to have this issue in the chapter title or with M-dashes. I haven't looked to see where the first instance is.
|
KFW |