Introducing Python

Errata for Introducing Python

Submit your own errata for this product.


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
ePub
Page loc.5900
to of "page", above time example

"The date module's time object is used to represent a time of day:" but the code uses the datetime module, not the date module. Sentence should refer to datetime?

Note from the Author or Editor:
I think you're correct, it should refer to datetime. That's what it's imported from.

robert montante  Nov 14, 2014  Feb 20, 2015
ePub
Page loc.4208
section "Structured Text Files", 3rd sentence

Should the sentence "You might want to save data for our program to use later..." read "You might want to save data for your program to use later..." ?

Note from the Author or Editor:
Ouch. Well, I guess it's "our" program if I'm in the room with you.I'll be right over.

robert montante  Nov 14, 2014  Feb 20, 2015
ePub
Page Loc 1182
Middle

letters[-1:0:-1] produces 'zyxwvutsrqponmlkjihgfedcb' not 'zyxwvutsrqponmlkjihgfedcba' To produce the latter string: letters[-1::-1]

Note from the Author or Editor:
Fixed this one and others in the slice section.

Richard Munde  Mar 07, 2014  Nov 07, 2014
ePub
Page Loc. 502
Top of page

1.0e8 does not mean "one to the eighth power or 100000000.0" since 1 to the eighth power is one. Rather it mean 1 times 10 to the eighth power which indeed is 100000000.0.

Note from the Author or Editor:
Corrected. Thanks!

Richard Munde  Mar 07, 2014  Nov 07, 2014
PDF
page 32: fifth and sixth paragraphs

letters[20:] is 'uvwxyz' not 'vwxyz' letters[12:15] is 'mno' not 'nop'

Note from the Author or Editor:
Fixed in Atlas.

Stephen Neuman  Mar 13, 2014  Nov 07, 2014
ePub
Page loc. 1568
"Things to do" 3.12

Problem 3.12 asks for a dictionary comprehension, but comprehensions aren't discussed until chapter 4.

robert montante  Oct 12, 2014  Nov 07, 2014
ePub
Page ??
About a quarter of the way down in the Comprehensions section

In the Comprehensions section, when beginning to introduce the ability to use conditional statements, it asks to find odd numbers between one and five. Instead it finds the numbers that when divided by 3, have a remainder of 1 (1 and 4). While this was confusing at first, it was helpful in understanding what that line of code did better.

Kyle Williams  Sep 30, 2014  Feb 20, 2015
ePub
Page loc. 1419
Figure 3-1

diagram of union: inner arc shouldn't be there; should be a single unified volume. diagram of intersection: the intersection should be shaded

robert montante  Oct 11, 2014  Nov 07, 2014
ePub
Page loc. 1421
sentence before section heding "Crfeate with set()"

"...an exanple of a null set..." should be "...an example of a null set..."

robert montante  Oct 11, 2014  Nov 07, 2014
ePub
Page loc. 1082
3rd paragraph after "Get a slice to Extract Items by Offset Range"

"The next exampe starts at..." should be "The next example starts at..." Also, why is "slice" not capitalized in the section heading?

robert montante  Oct 11, 2014  Nov 07, 2014
ePub
Page loc. 885
end of "Get Length wit len()" section

Last sentence reads "You can use len() with other sequence types, too, as is described see in Chapter 3." Word "see" should be omitted?

robert montante  Oct 11, 2014  Nov 07, 2014
ePub
Page loc. 2274
example code "def document_it(func):"

In the code for "document_it(func)" , and also in the code for "square_it(func)" later on in the same section, the lines: def new_function(*args, kwargs): result = func(*args, kwargs) should have double asterisks in front of "kwargs", like this: def new_function(*args, **kwargs): result = func(*args, **kwargs)

Note from the Author or Editor:
Fixed in QC2. We lost those asterisks in formatting somewhere. Thanks! I would have hated to see that in print.

robert montante  Oct 18, 2014  Nov 07, 2014
PDF
Page 5
4d paragraph

The follwing code-snippet: import requests url = "https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?alt=json" response = requests.get(url) data = response.json for video in data['feed']['entry'][0:6]: print(video['title']['$t']) Returns: Traceback (most recent call last): File "ex2.py", line 5, in <module> for video in data['feed']['entry'][0:6]: TypeError: 'method' object is not subscriptable I used python3.2 on Debian 7.4 to run the code which I previously saved in ex2.py, The module requests was installed.

Note from the Author or Editor:
Fixed. Lost the () in cut & paste.

Anonymous  Mar 06, 2014  Nov 07, 2014
PDF
Page 23
United States

the line : first, 3 * 4 is 12, and 2 * 12 is 14. In Python, as in most languages, multiplication has 2 * 12 is 14 - should be 2 + 12 is 14

Note from the Author or Editor:
Drat. The first one confirmed.

Mike LeRoy  Dec 04, 2014  Feb 20, 2015
PDF
Page 29
United States

>>> print(poem2) I do not like thee, Doctor Fell. The reason why, I cannot tell. But this I know, and know full well: I do not like thee, Doctor Fell. >>> The words "not", "and" & "not" are in black when the rest is blue. When I run this using Ipython there is no indent. A little further down the page the response is in red and blue with "and" & "not" in black

Note from the Author or Editor:
This is an artifact of the PDF production process. The poem text was treated as code, and "not" and "and" are reserved words in Python.

Mike LeRoy  Dec 04, 2014  Feb 20, 2015
PDF
Page 30
just after subtitle "Combine With +"

page 30 (Chapter 2 "Combine with +") the first line reads: a = ' it should read: a = '' otherwise the interactive interpreter will return an error after the line. This actually is minor typo except that it would return the error. Good luck. Introducing Python early release revision 2 ISBN: 978-1-449-35936-2

Note from the Author or Editor:
Fixed at some point.

Donald Altman  Apr 13, 2014  Nov 07, 2014
PDF
Page 32, 33
see below

letters[::7} is 'ahov' and not 'ahpq' letters[4:20:3] is 'ehknqt' and not 'ehloru' letters[19:4] is 'tx' and not 'uy' letters[:21:5] is 'afkpu' and not 'aflqv'

Note from the Author or Editor:
Those have been fixed in Atlas. I don't know when an update will be made available.

Anonymous  Mar 13, 2014  Nov 07, 2014
PDF
Page 33
3rd paragraph from end

Using a plain : is the same as 0:-1 (the entire string): letters[:] 'abcdefghijklmnopqrstuvwxyz' If I use letters[0:-1] it is not the same as letters[:]. It returns 'a-y', while letters[:] returns 'a-z'.

Anonymous  Dec 29, 2014  Feb 20, 2015
Printed
Page 38
bottom

replace() replaces all instances, if count is missing.

dan  Dec 20, 2014  Feb 20, 2015
Printed
Page 38
Swap upper- and lowercase: example

If setup = 'a duck goes into a bar...' (p37), then: >>> setup.swapcase() returns: 'A DUCK GOES INTO A BAR...' not 'a DUCK GOES INTO A BAR...'

Note from the Author or Editor:
Fixed in the third printing.

Joe   Feb 27, 2015  Feb 26, 2016
PDF
Page 45
Tip icon text

Description reverses LIFO and FIFO process. Pop(0) should give FIFO; pop() gives LIFO.

Note from the Author or Editor:
Fixed in ms. Thanks!

Anonymous  May 21, 2014  Nov 07, 2014
ePub
Page 45
Get items by offset range with a slice

The example marxes[::2] is shown to display ['Grouch', 'Harpo'] as the value returned. If the user has been following along withthe examples, ['Groucho', 'Wanda'] will be returned. In a previous example Wanda was substituted for Harpo.

Note from the Author or Editor:
Thanks for catching this.I've notified production to add the line to define the marxes list first.

Nick  Sep 19, 2014  Nov 07, 2014
ePub
Page 48/49

Test for a key with inIf you want to know whether a key exists in a dictionary, use in. Let�s redefine the pythons dict again, omitting a name or two, chen checking to... Chen instead of then

Note from the Author or Editor:
Fixed. Thanks!

Scott Le Camp  Mar 11, 2014  Nov 07, 2014
PDF
Page 56
Top: "Are all the characters in the poem either letters or numbers?"

Starting at the tenth line of text: Are all the characters in the poem either letters or numbers? >>> poem.isalnum False Nope, there were some punctuation characters. Should read >>> poem.isalnum() Parenthesis missing in the book.

Nick  Sep 15, 2014  Nov 07, 2014
Printed
Page 65
5th and 6th text paragraphs, as opposed to example code

The formatting of these two items actually led me astray as I am new to Python. The first states - "proper subset ... Calculate by using <:" Then the example just uses a < . The second states - "proper superset ... and more) by using >:" Then this example just uses the > . I honestly was not sure if I was supposed to use the less-than-sign and a colon, a greater-than-sign and a colon; or were the colons omitted from the example text. Took me a trip to Python. org to clarify that the colons were the books formatting. Perhaps a space between the *-than-sign and the final paragraph colon would be beneficial to others.

Note from the Author or Editor:
Good advice, and I've fixed these for the third printing.

Al Szymanski  Nov 05, 2015  Feb 26, 2016
PDF
Page 87
United States

>>> def echo(anything): ... ... return anything ' ' anything ... >>> gives invalid syntax with in ipython 3 and python 2.7 Should be: return anything + ' ' + anything

Note from the Author or Editor:
You're right, the line should be: return anything + ' ' + anything Looks like we lost the + signs in formatting.

Mike LeRoy  Dec 05, 2014  Feb 20, 2015
PDF
Page 101
def change_and_print_global() example

The line: "File "<stdin>", line 2, in change_and_report_it" should read "File "<stdin>", line 2, in change_and_print_global". The function name most likely was changed at some point but the example code was not fully updated.

Note from the Author or Editor:
Fixed in the third printing.

rifferte  Jun 25, 2015  Feb 26, 2016
PDF
Page 106
Answer tro Things to do 4.9

You provide a solution with enumerate() (for count, number in enumerate(get_odds(), 1):) but enumerate isn't explained until "Import a Module with Another Name" (Chapter 5)

Note from the Author or Editor:
I changed the answer to example 4.9 and replaced the enumerate() with a counting loop.

Anonymous  Dec 30, 2015  Feb 26, 2016
PDF
Page 111
Second code block

The lines printed by the program (like "Today's weather: who knows") look like they picked up some unintended syntax highlighting (the apostrophe is treated as a single quote and everything following is in red).

Note from the Author or Editor:
Fixed in the third printing. Some plain text was highlighted as Python code.

Ben Nathanson  Mar 13, 2015  Feb 26, 2016
PDF
Page 123
2nd paragraph

"As I mention in Chapter 1, everything in Python...is an object." Should say Chapter 2.

Note from the Author or Editor:
You are correct, and we'll fix it. Thanks.

Ben Nathanson  Feb 11, 2015  Feb 20, 2015
ePub
Page 130
Ch.8, "Write a text file with write", roughly page 130 of ePub.

"For some reason, there aren't many limericks about general relativity". There are none, as far as I know. This limerick refers to SPECIAL relativity. An esoteric point, I know, but, as a physicist, I couldn't let this one pass. And if you ever do find a limerick about general relativity, I'd love to hear it.

Note from the Author or Editor:
That is the best erratum I've ever seen. Thanks! Maybe I can find something about inflation or entanglement?

Martin Ward  Apr 06, 2014  Nov 07, 2014
PDF
Page 131
Table 6-1

This table describes python's testing methods. In the table the last two methods appear to be incorrect. In the document: __lt__(self, other) self <=other __le__(self, other) self >=other It should read: __le__(self, other) self <=other __ge__(self, other) self >=other

Note from the Author or Editor:
Thanks for catching this.

Jerald Jackson  Apr 01, 2014  Nov 07, 2014
PDF
Page 140
First Paragraph(Code Snippet)

class Word(): ... def __init__(self, text): ... self.text = text ... def __eq__(self, word2): ... return self.text.lower() == word2.text.lower() ... def __str__(self): ... return self.text ... def __repr__(self): ... return 'Word("' self.text '")' In this code snippet, __repr__ shoul return "Word('" + self.text + "')", not 'Word("' self.text '")' . This code snippet doesn't do what author wants, and doesn't even work when we enter.

Note from the Author or Editor:
Confirmed formatting error, it does need the + between the strings after 'return'.

Anonymous  May 02, 2015  Feb 26, 2016
PDF
Page 140
Second Paragraph

I suggest author to explain aggregation and compositon in more detail. It was hard to understand, but thanks to Lynda tutorial I understood. Author claims book is suitable for beginners, but I think his OOP explanations are not enough for a beginner.

Note from the Author or Editor:
I've updated the text with definitions of "has" (composition) and "uses" (aggregation).

Anonymous  May 02, 2015  Feb 26, 2016
Printed
Page 140
Definition of about(self) method of Duck class

The implementation of about(self) uses the global names 'bill' and 'tail', not instance variables. As written: def about(self): print('This duck has a', bill.description, 'bill and a', tail.length, 'tail') Should be: def about(self): print('This duck has a', self.bill.description, 'bill and a', self.tail.length, 'tail') Problems that will be encountered using published code: >>> tail = Tail('long') >>> bill = Bill('wide orange') >>> duck = Duck(bill, tail) >>> duck >>> duck.about() This duck has a wide orange bill and a long tail >>> duck2 = Duck(Bill('narrow green'), Tail('short')) >>> duck2.about() This duck has a wide orange bill and a long tail >>> bill = Bill('purple') >>> duck.about() This duck has a purple bill and a long tail >>> duck2.about() This duck has a purple bill and a long tail >>> del(bill) >>> duck.about() Traceback (most recent call last): File "<pyshell#237>", line 1, in <module> duck.about() File "<pyshell#221>", line 6, in about print('This duck has a', bill.description, 'bill and a', NameError: name 'bill' is not defined

Note from the Author or Editor:
Thanks for catching this. You are completely correct, and your example code proves it. I regret the error. I would blame my cat, but this one wasn't his fault.

Jeff Bienstadt  Aug 05, 2015  Feb 26, 2016
Printed
Page 140
in code example

The Duck class's about() method refers to "bill.description" and "tail.length". These are the global objects "bill" and "tail", created a little later. To show the values for the "bill" and "tail" attributes of a Duck object, use "self.bill.description" and "self.tail.length".

Bill Lubanovic
Bill Lubanovic
 
Jan 18, 2016  Feb 26, 2016
ePub
Page 150
Things to do 7.14

The book says that the pixel width and height of a GIF are encoded as 16-bit big-endian integers, whereas the GIF specification (and indeed the encoded GIF snippet in the book) suggest they are little-endian 16-bit integers. This makes this "thing to do" quite confusing, as it left me wondering what I did wrong!

Note from the Author or Editor:
You're correct. Example 7-14 needs to say that the pixel width is a 16-bit little-endian integer. The example solution in Appendix E uses the correct little-endian specifier (<HH), but repeats the wrong information in the question.

Stefan Zwanenburg  May 16, 2015  Feb 26, 2016
PDF
Page 153
top

The Pattern Matches table at the top of page 153 shows the following: prev+? one or more prev, as few as possible prev+? one or more prev, as many as possible The table actually starts on the previous page (152) where both of the above possibilities are noted. Not to mention that the second is incorrect, I believe. It should read "prev+ one or more prev, as many as possible".

Note from the Author or Editor:
You're right, I had duplicated those two lines. Thanks.

Jerald Jackson  Apr 01, 2014  Nov 07, 2014
PDF
Page 170
United States

Question 7.3 decode pop1 should be pop_bytes

Note from the Author or Editor:
You are right, it's referring to pop_bytes from the previous question. Or at least, it was supposed to.

Mike LeRoy  Dec 12, 2014  Feb 20, 2015
PDF
Page 171
Exercise 7.14

The exercise 7.14 begins with: "The pixel width of a GIF is a 16-bit big-endian integer". It's wrong, the byte order is little-endian, as can be seen here http://www.onicos.com/staff/iz/formats/gif.html. Using big endian leads to the wrong result: >>> struct.unpack('>2H', gif[6:10]) (256, 256) Using little endian leads to the correct result: >>> struct.unpack('<2H', gif[6:10]) (1, 1)

Note from the Author or Editor:
The word 'big' has been corrected to 'little' in the text for the third printing. The answer in the appendix has the correct '<' for little-endian.

Lorenzo Gasparini  Jun 19, 2015  Feb 26, 2016
Printed
Page 175
Last line on page

Extraneous ']' (closing square bracket) on call to open() Printed code: >>> try: ... fout = open('relativity', 'xt')] Should be: >>> try: ... fout = open('relativity', 'xt')

Note from the Author or Editor:
Yes, that final right bracket is a formatting error.

Jeff Bienstadt  Aug 10, 2015  Feb 26, 2016
Printed
Page 197
middle paragraph, second line of text

"...those three values as a list..." should be "...those three values as a tuple..." Using a list seems to work, but the code uses a tuple and the explanation should be consistent.

Note from the Author or Editor:
Corrected in the third printing.

Jeff Bienstadt  Aug 11, 2015  Feb 26, 2016
Other Digital Version
201 of 21403
bottom of that location

The author is telling on this page about "special words" and on the same page an example-output it wrongly formatted, thereby confusing the reader. Because it would make Python a very very bad tool, if normal strings would behave funny whenever they contained any of the "special words". So this formatting error in the worst possible location. Here it is located: --- The program prints the fourth cliché: Be that as it may --- source: Lubanovic, Bill (2014-11-11). Introducing Python: Modern Computing in Simple Packages (Kindle Locations 216-218). O'Reilly Media. Kindle Edition. In this Kindle-Edition the example-output sentence "Be that as it may" has got the word "as" in bold, but (since it is output) is should NOT be emphasised. The Kindle-Edition is probably using styles for any Python code, but this output is not code, so maybe all it needs is assigning the correct style...

Note from the Author or Editor:
This is fixed in the third printing. It was being formatted as Python code, not plain text.

Martin Zaske  Aug 12, 2015  Feb 26, 2016
Printed
Page 220
final interpretor code

url 'http://www.iheartquotes.com/api/v1/random' does not work anymore.

Note from the Author or Editor:
Another dead free web API! It's hard to find these, since almost all web APIs require registration and a key now. Replaced it with a call to omdbapi.com (a movie search service), which I hope lives longer.

Greg Kedrovsky  Dec 22, 2015  Feb 26, 2016
ePub
Page 222
Roughly 1 page after section title "RPCs"; then end of OpenStack section.

Section on RPCs, ePub page 222. "The function we'll providing on the server..." should be "The function we'll be providing on the server..." Just after OpenStack section, page 229. "Things to to" should be "Things to do".

Note from the Author or Editor:
Fixed both of them. Thanks.

Martin Ward  Apr 06, 2014  Nov 07, 2014
Printed
Page 229
second code block

in the echo function we are returning 'thing' but which will print just the text we use in the url. Further down the page the statement is made that we should see the full 'Say hello to my little friend: ' string but we don't because it is not included in the echo function.

Note from the Author or Editor:
Yes, /echo should just output Godzilla. Looks like I pasted output from the upcining template example.

Micheal Beatty  Dec 27, 2014  Feb 20, 2015
PDF
Page 232
United States

from flask import Flask, render_template needs to be from flask import Flask, render_template, request

Note from the Author or Editor:
Yes, it should have the same imports as the example on the previous page.

Mike LeRoy  Jan 05, 2015  Feb 20, 2015
PDF
Page 265
Second code example, showing a queue

In def dryer(dish_queue) function, `while True` is indented 2 times. It should be indented only once. So as it is now, it should be moved four spaces to the left.

Note from the Author or Editor:
Yep, that's a formatting error. I'll check the corresponding github code.

Anton Antonov  Nov 28, 2014  Feb 20, 2015
Printed
Page 266
code at the top of the page

dryer_thread.start() is indented 8 spaces, but should only be indented 4.

Note from the Author or Editor:
Fixed in the third printing.

Anonymous  Dec 15, 2015  Feb 26, 2016
Printed
Page 272
code in the middle of the page

In the code for redis_washer.py, num is not defined. I think what you had in mind was dish rather than num.

Note from the Author or Editor:
You are right. Changed 'num' to 'dish' for the third printing.

Anonymous  Dec 15, 2015  Feb 26, 2016
Printed
Page 278
First sentence of ZeroMQ section

The first sentence of the ZeroMQ section asks, "Remember those ZeroMQ PUB and SUB sockets a few pages ago?" However, these did not occur before this page. There is a prior mention of ZeroMQ on page 276, in the first paragraph, where it states that we have already touched on it, but I am fairly certain we did not. The index entry for ZeroMQ puts its first mention on page 278.

Note from the Author or Editor:
I've fixed this continuity problem.

Anonymous  Dec 17, 2015  Feb 26, 2016
PDF
Page 315
in just_do_it def

missing "#" in front of Capitalize

Note from the Author or Editor:
Also on page 317 of the print edition.

Mike LeRoy  Jan 29, 2015  Feb 20, 2015
Printed
Page 330
just over halfway down the page

Sentence reads: The syntax is timeit.timeit(code, number, count). I think it should instead say: The syntax is timeit.timeit(code, number=count).

Note from the Author or Editor:
You are right, and this is now fixed for the third printing.

Anonymous  Dec 24, 2015  Feb 26, 2016
Printed
Page 392
2nd paragraph from bottom

The link given to install Anaconda 2, http://repo.continuum.io/anaconda3 did not work for me. A quick Google search lead me to http://continuum.io/downloads to get Anaconda.

Note from the Author or Editor:
Fixed for the third printing.

Robert St. Pierre  Apr 20, 2015  Feb 26, 2016
Printed
Page 412
Question 7.11 answer

Hello, The regular expression given for in the answer of the question 7.11 is wrong. The question is "Find all the words that contain exactly three vowels in a row." And you gave this solution for the regex : r'\b\w*[aeiou]{3}[^aeiou]\w*\b' The problem is: 1/ the first \w* can match an infinity of vowels. 2/ the last \w* can match an infinity of vowels. There's no such word in the testing string called mammoth, but if you add this word 'Squuuuuueeeeeeezze', you'll see that it matches. So the regular expression doesn't work.

Note from the Author or Editor:
You are correct, and this is a good example of incomplete test examples. The pattern should be any number of non-vowels, followed by three vowels, followed by any number of non-vowels. >>> import re >>> pat = r'\b[^aeiou]*[aeiou]{3}[^aeiou]*\b' >>> re.findall(pat, 'abc aaa eeek niiii nooo') [' aaa ', 'eeek ', ' nooo']

Anthony Hocquet  Nov 24, 2015  Feb 26, 2016
Printed
Page 413
second line of first group interpretor code under 7.8

The line of code just under "import re" reads "re = r'\bc\w*'" and it should (I believe) read "pat = r'\bc\w*'". The "re" appears to be a type and should be the variable "pat" for the regex pattern.

Note from the Author or Editor:
Fixed in the third printing.

Greg Kedrovsky  Dec 22, 2015  Feb 26, 2016