Errata

Learning Python

Errata for Learning Python, Sixth 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.

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.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page various
various

Page 311: The word continue is broken across lines:
... such as break and con
tinue, the loop else ...

Page 462: The function name sumtree is broken across lines:
... filename makes it unique, and sum
tree is always the latest version imported ...

Page 491: The function name StopIteration is broken across lines:
... becomes the value attribute of the StopItera
tion exception ...

Page 518: The function name asyncio is broken across lines:
... pause with sleep calls in both time and asyn
cio to simulate a long-running task. ...

Page 533: The function name runner is broken across lines:
... defines a function named run
ner that takes any number of test functions ...

Page 589: The name sys.modules is broken across lines:
... get a handle on the module, but the sys.mod
ules scheme may be useful in programs ...

Page 625: "It’s buy-one-get-one code." should be "It’s buy-one-get-two code.".

Page 664: "Outside" should be lowercase:
>>> x.data = 'hacking' # Can get/set attributes
>>> x.display() # Outside the class too

Page 692: The name Manager is broken across lines:
... existing software and are available on Man
ager objects only, not on Persons. ...

Page 693: The name Manager is broken across lines:
... in its entirety, renamed the copy to Man
ager, and changed its giveRaise ...

Page 696: The word __getattr__ is broken across lines:
... and lastName triggers __get
attr__ to reroute to the embedded object. ...

Page 696: The word Person is broken across lines:
... Manager isn’t really a Per
son here, so we need extra code ...

Page 837: The word classmethod is broken across lines:
... functions named staticmethod and classme
thod within the class or invoke them ...

Page 889: "different" should be "no different":
... This else role may seem different than in if and loops, but this context differs. ...

Page 891: The word TypeError is broken across lines:
... catches and recovers from the Type
Error Python raises immediately ...

Page 924: The word LookupError is broken across lines:
... clause gobbles IndexError via its LookupEr
ror superclass, along with ...

Page 939: The word SystemExit is broken across lines:
... can help because it is not a superclass of System
Exit: ...

Page 955: The word isalpha is broken across lines:
... with operations that assume characters (e.g., the isal
pha method), the contents of bytes objects ...

Page 975: The word encoding is broken across lines:
... name to be passed in with an encod
ing argument to open and use it to ...

Page 982: The word getpreferredencoding is broken across lines:
... accessed via open is fetched with locale.getpreferred
encoding(False). ...

Page 983: The word getpreferredencoding is broken across lines:
... way that open and the older getpreferred
encoding(False) in locale are. ...

Page 983: The word output.txt is broken across lines:
... redirected to files on Windows and others (e.g., > out
put.txt)…except when you or a Python of the future ...

Page 1118: The word classmethod is broken across lines:
... nonclass instance are bound to the instance unless class
method or staticmethod are used ...

Page 1176: The word operator.mul is broken across lines:
... skip an iteration, and fact2 could use reduce(oper
ator.mul, range(N, 1, −1)) to avoid a lambda. ...

Page 189: Key/value pairs usually come with a space after the ":". Here, there is no space after ":":
>>> D2 = {'code':4, 'hack':5, 'app': 6} # New keys added, app:6 wins

Page 330: Same as above for page 189 (I'm, sure there are a few more occurrences of this):
>>> D1 = {'app': 1, 'script': 3, 'program':5}

Anonymous  Feb 17, 2026 
PDF Page 233
last paragraph

"is the" is repeated:
... (e.g., types.FunctionType is the is the type of functions) ...

Anonymous  Feb 17, 2026 
Printed Page 495
Chapter 20 - The yield from extension

The 2nd sentence of the 3rd paragraph on page 495 reads: "In the following, for example, two generators yield from others, the last of which ultimately uses yield to send results up though the chain:"

I suppose that "up though" near the end of the sentence should be "up through".

Wu Qi  Dec 13, 2025 
Printed Page 518 (Chapter 20 - Section "Running serial tasks with normal blocking calls")
3rd sentence in the 6th paragraph

In the sentence "To work along, ether cut and paste from this file or emedia, or run the examples file in its entirety or with parts stubbed out with triple quotes.", I suppose that "ether cut and paste" here should be "either cut and paste".

Wu Qi  Dec 13, 2025 
Printed Page 546
4th line in Example 21-9. pybench_tests.py (Chapter 21 - Section Benchmark script)

In the docstring of the module pybench_tests.py, the last paragraph starts with "Edit stms below to change tested code".

I suppose that "stms" here should be "stmts" referring to the variable used in the code snippet below the docstring.

Wu Qi  Dec 14, 2025 
Printed, PDF Page 793 (Chapter 31 - Section Bound Methods in Action)
2nd last paragraph

The 2nd sentence of the 2nd last paragraph starts with "To call them though an instance, too, though, you’ll have to ...".

I suppose that the first "though" as in "To call them though an instance" here should be "through".

Wu Qi  Dec 24, 2025 
Printed, PDF Page 830
Code snippet after the 3rd paragraph (Chapter 32 - Section Handling slots and other “virtual” attributes generically)

The last comment in the code snippet after the 3rd paragraph reads: # applies to slots, properties, descrip.

I'm not sure whether the author meant to use "descrip" as a short form of "descriptor", but I think at least the plural form should be used for consistency ("descriptors" or "descrips").

Wu Qi  Dec 26, 2025 
Printed, PDF Page 955 (Chapter 37 - Section Text and Binary Files)
Last paragraph (bullet)

The last paragraph (bullet) on this page reads: ... and CVS or XML files ...

I don't know what "CVS files" are. I guess that the author probably meant "CSV files" in this context?

Wu Qi  Jan 02, 2026 
Printed, PDF Page 964 (Chapter 37 - Section Source-File Encoding Declarations)
Last paragraph in the comments at the top of Example 37-1

The first sentence of the comments at the top of "Example 37-1. source-encoding-latin1.py" reads: ... to make its mystr1 text match.

I suppose that "mystr1" here should be styled as "myStr1" to match the capitalization of the variable name declared below.

Wu Qi  Jan 04, 2026 
PDF Page 992 (Chapter 38 - Section Why Manage Attributes?)
2nd def in the code snippet at the top

The class Person defined in the code snippet at the top of this page are formatted as:

class Person:
def getName(self):
if not valid():
raise TypeError('cannot fetch name')
else:
return self.name.transform()

def setName(self, value):
if not valid(value):
raise TypeError('cannot change name')
else:
self.name = transform(value)

Note that the if clause in the method "setName" is not indented consistently (extra 1 space).

Wu Qi  Jan 04, 2026 
PDF Page 1051-1053 (Chapter 39 - Section Using descriptors to decorate methods)
Example 39-6/7/8

The "tracer" class in the three decorator examples all inherit explicitly from the built-in "object" class.

This is the old-style Python 2 class declaration. In Python 3, this is harmless but redundant. As it is claimed in the preface that this book drops coverage of Python 2.X (Page xxxi), it would be better off to use the new-style Python 3 class declaration (except on Page 825 for explaining implicit inheritance from the built-in "object") to avoid creating confusion to newcomers and improve consistency with other examples throughout this book.

Wu Qi  Jan 06, 2026 
PDF Page 1120 (Chapter 40 - Section Operator Overloading in Metaclass Methods)
2nd paragraph

The 2nd paragraph on this page reads: ... when both class and metaclass overload the same operator, the former applies to classes and the latter to nonclass instances:

Here I suppose the author meant: class's overloading method applies to nonclass instances and metaclass's overloading method applies to classes, as implied by the comments in the code snippet below. So I suppose that "the former" and "the latter" parts (or "class" and "metaclass" as in "both class and metaclass overload ...") should be swapped.

Wu Qi  Jan 09, 2026 
PDF Page 1135 (APPENDIX A)
4th paragraph

The 2nd sentence of the 4th paragraph on this page reads: ... and plan to
consult the latest resources if when this story changes.

I'm not sure why the word "if" is strikethrough text. Maybe the word is meant to be removed from the text?

Wu Qi  Jan 09, 2026