Errata

Introducing Python

Errata for Introducing Python, Second Edition

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
n/a
Chapter 11, Section "Packages"

In Chapter 11, Section entitled "Packages", the examples show the use of:
from sources import fast, advice
stating that the two files are in the "sources" directory relative to the current working directory. After that, throughout this section, the directories "sources" and "choices" seem to be used; I am suspecting "choices" was first used, then changed to be less confusing in the examples. If I am wrong, please elaborate why "choices" is used as a directory.

Michael Cohen  Nov 05, 2019 
ePub
Page n/a
example 11-1 fast.py

from random import choice

places = ['McDonalds", "KFC", "Burger King", "Taco Bell",
"Wendys", "Arbys", "Pizza Hut"]

def pick(): # see the docstring below?
"""Return random fast food place"""
return choice(places)


The string McDonalds begins with a single quote.

Arun M  Nov 30, 2019 
Printed,
Page ch7
1st, 2nd

In chapter 7, "Typles and lists", under "Modify a tuple" section

t2 = ('Flop,')

should be

t2 = ('Flop',)

in the first two examples in order to generate a tuple. (It is correct in the third).

(No page numbers as I am reading it only on oreilly.com)
Regards

Anonymous  Jan 11, 2020 
Printed
Page xxxvii
Section "Using Code Examples", Line 2

https://github.com/madscheme/introducing-python
The code repository seems to be for 1st edition.

Note from the Author or Editor:
I will update these soon.

Ryoko  Feb 14, 2020 
Chapter 4
"New: I Am The Walrus" section

This is the section where you introduce the "walrus" operator, := as of Python 3.8.

The line in the example with the walrus operator is:

if diff := tweet_limit - len(tweet_string) >= 0:

The code snippet "works", but somewhat accidentally. I think the mistake is that the diff variable, instead of containing the value of tweet_limit - len(tweet_string), which is clearly what was intended, instead has the boolean value of True, which in the case of the code by chance gives the expected output. This is because the := operator has the lowest precedence. I believe the line should instead be coded as:

if (diff := tweet_limit - len(tweet_string)) >= 0:

Note from the Author or Editor:
You are correct. The current line resolves to True, which has the integer value 1.

The line should read:

if (diff := tweet_limit - len(tweet_string)) >= 0;

Howard Sherman  Feb 23, 2020 
n/a
In the "Decorators" section of Chapter 9

This example function and decorator definition:

>>> @document_it
... def add_ints(a, b):
... return a + b
...
>>> add_ints(3, 5)
Start function add_ints
Positional arguments: (3, 5)
Keyword arguments: {}
Result: 8
8

... should produce this output:

>>> @document_it
... def add_ints(a, b):
... return a + b
...
>>> add_ints(3, 5)
Running function: add_ints
Positional arguments: (3, 5)
Keyword arguments: {}
Result: 8
8

Note the difference in the first line of printed output, namely the incorrect message "Start function add_ints" versus the correct message "Running function: add_ints" respectively.

Robert Morel  Nov 06, 2019 
2
Variables

keyword.kwlist() => keyword.kwlist
kwlist is not a callable function, instead its a attribute of type list.

Note from the Author or Editor:
Fixed during editing. Thanks!

Gaurov Soni  Sep 06, 2019 
Page 5
6th bullet point, 2nd sentence

"The recipe assumes you that know what water is and how to boil it."

That's a grammar error.

It should be either:

"The recipe assumes you know what water is and how to boil it."

or

"The recipe assumes that you know what water is and how to boil it."

Gio J  Sep 12, 2022 
Printed
Page 42
6th paragraph, middle of this page.

“and then assigning it to a on the left side of the + sign.” should be “and then assigning it to a on the left side of the = sign.”

Evan Lai  Jan 04, 2020 
Page 97
Create with [] example

In Chapter 7: Tuples and Lists, the following example is provided in the "Create with []" introduction to lists:
>>>randomness = ['Punxsatawney", {"groundhog": "Phil"}, "Feb. 2"}

From what I've learned so far, this seems to contain 2 errors: an "unterminated string literal" and "closing parenthesis '}' does not match opening parenthesis '['".

Instead, a correct example might read:
>>>randomness = ['Punxsatawney', {"groundhog": "Phil"}, "Feb. 2"]

Note from the Author or Editor:
All quotes should be single.

Alex Jestice  May 23, 2022 
Page 168
Middle of the page, 2nd code block

The exception mentioned in the 1st code block is called "UppercaseException" but in the 2nd code block it references an undefined exception called "OopsException". So when you try to run that code in Python you get:

NameError: name 'OopsException' is not defined

I believe the author meant to use the existing defined exception "UppercaseException" thus when using that, the code now runs with output shown in the book right above the "Coming Up" section.

Note from the Author or Editor:
Yes, I should have used UppercaseException here.

Anonymous  May 02, 2022 
Page 203
Multiple places

In the previous page (202) at the bottom, it says:

"Now make a subdirectory named "choices".

So far so good but then in the next page (203), Example 11-7 questions.py you reference import libary "sources" in the line of code:

"from sources import fast, advice"

This does not work as it should be "from choices....."

And then everywhere else on this page (203), the name "sources" should be replaced with "choices".

Gio J  Sep 12, 2022 
Page 211
Suggested section (where image of crow bird is)

The last sentence says:

"The examples in this section are relevant only if you're a version of Python earlier than 3.7."

It should read:

"The examples in this section are relevant only if you're using a version of Python earlier than 3.7."

Gio J  Sep 12, 2022 
Page 248
1st paragraph

The phrase "daylight savings time" is used where the correct term is "daylight saving time".

Darryl Pierce  May 11, 2022 
Page 262
Next to last code example on the page

In the line of code:

fout = open('relativity', 'xt')]

There is a code error with the extra right brace at the end which when compiled leads to the error:

SyntaxError: unmatched ']'

Gio J  Sep 12, 2022 
Page 262
2nd to last code example

In the print statement it says

print('relativity already exists!. That was a close one.')

There's no need for a period after the exclamation point after the word 'exists'
It should read as follows:

print('relativity already exists! That was a close one.')

Gio J  Sep 12, 2022 
PDF
Page 312
Second line from bottom

((("dump()
function")))((("load() function")))

is a piece of index markup, and should be deleted.

Bill Lubanovic
Bill Lubanovic
 
Dec 06, 2019 
PDF
Page 525
final paragraph

The formatting of the "Queues" section should match the preceding ones.

madscheme  Dec 09, 2019 
Printed
Page 552
ans for 12.1 and 12.5 (pg 554)

In ans 12.1 the mystery code is '\U0001f4a9' (pile of poo) but in the Things to Do page (pg 245) the mystery code is '\U0001f984'

In the ans for 12.5, regular expression should have [C|c]. That is, to look for upper and lower case 'c'. The word 'Cows" is missing in the list.

Note from the Author or Editor:
For the 12.1 example, you're right. Try looking up '\U0001f984'.

For the 12.5 example, I specified 'c', which is lower case and technically true, but I didn't say to only look for the lower-case version.

wesley lee  Apr 03, 2020