Python in a Nutshell

Errata for Python in a Nutshell

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
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 88
Kinds of arguments section

Original contents as follow: if there are more positional arguments that positional parameters, That should be: if there are more positional arguments than positional parameters,

Note from the Author or Editor:
The reader is correct, and the phrase should read "if there are more positional arguments than positional parameters," This is actually on page 91.

Cendey  Aug 14, 2017 
Printed
Page 91
top line

Correction of errata. The first error in the error list if there are more positional arguments that positional parameters ---- is not located on page 88 but on page 91 in the top line of the printed version.

Eckhard Stein  Oct 31, 2018 
Printed
Page 95

On line 3 in the last example an odd character has slipped in. Instead of "return low<=value><high" the line should read: return low <=value<high

Note from the Author or Editor:
Reader is correct. Should be: return low <= value < high

Werner Wenzel  May 21, 2017 
PDF
Page 131
Code example at the bottom of the page

I believe the code should read this: if isinstance(index, slice): return self.__class__(self[x] for x in range(*index.indices(len(self)))) i.e. there should be a call to index.indices() instead of self.indices(). The text above states that slice objects provide the indices() method.

Note from the Author or Editor:
At the bottom of p.133 (printed edition) under `Container slicing`, change the expression `self.indices(len(self))` into `index.indices(len(self))`.

Tomas Linhart  Dec 26, 2017 
Printed
Page 245
Paragraph "Formatting of user-coded classes"

1st subparagraph: The 2nd example math.pi.__format__('18.6') should be preceded by import math lest "NameError: name 'math' is not defined" is triggered. 2nd subparagraph: The 1st formatting call should replace "s" by "my_s" and read '{:format_string}'.format(my_s) Its result should read Format string: format_string '42' The 2nd formatting call should replace "s" by "my_s" and read 'The formatted value is: {:anything you like}'.format(my_s)

Note from the Author or Editor:
Hi Werner, Thanks very much for letting us know about the issues you have found with the third edition. I agree that the math.pi reference would cause a NameError exception for the unwary reader. Rather than adding an import statement, however, I think it might be better to replace "math.pi" with a specific numeric value that doesn't require an import. I'd therefore suggest we change the line in question to read 3.141592653589793.__format__('18.6') This would give the same result but would not require an import. As to the second item, I confirm that you have caught me out there (I wrote that particular bit of the text, so Alex and anna are blameless except for failing to catch my error in proof). The last executable line on p245 should indeed read 'The formatted value is: {:anything you like}'.format(my_s) as you state. We are all grateful for the scrutiny of diligent readers such as you, and I hope these minor issues don't impede your enjoyment of the rest of the book. regards Steve

Werner Wenzel  Jul 15, 2017 
PDF
Page 295
The os.path Module section

at the end of the - expandvars expandvars(path) section, the last line says: emits /u/alex/foo/. os.path.expanduser expands a leading ~ to the path of the home directory of the current user. but that line - os.path.expanduser expands a leading ~ to the path of the home directory of the current user. should either be on it's own line or part of it's own entry, it's not clear.

Anonymous  Nov 28, 2016  Apr 06, 2017
Printed, Safari Books Online
Page 569
example in add_password

In the line auth = urlib2.HTTPBasicAuthHandler(x) urllib2 is missing an L. It should read: auth = urllib2.HTTPBasicAuthHandler(x)

Anna Martelli Ravenscroft
 
Sep 28, 2017 
Printed
Page 624
3rd paragraph

Paragraph describes how a dictionary can be used with string formatting to replace placeholders in curly braces. Code example is: t.format(d), should be: t.format(**d).

Note from the Author or Editor:
Good eye! No matter how much effort we expend on proofreading and testing there's always the odd glitch that slips through. You are indeed correct that in order to select dictionary values by name the dict must be converted to keyword arguments by use of the ** operator. We'll correct this as you suggest in future issues - thanks for taking the time to report it. SH

Bob Polis  Jul 31, 2017