This is the official place where updates and corrections for the 1st
Edition of the book Learning Python
are maintained.
It's traditional to call this an "errata" page, but we'll also post
miscellaneous updates and supplements here as well (some of the items
below don't require changes in the text). This page was last updated
on 12/03/02.
The updates below are grouped by printing number, and ordered by page
number within printing. There is just one edition of the book, but we
fix typos when the book is reprinted. In other words, items listed
below for a given printing of the book may not be present in
later printings of the book. See the date on the lower right side of
the inside cover pages to see which printing you have. Also note that
any bugs posted here have been fixed in the source-code
examples file.
Comments and typo reports are very much appreciated; we want to
make this book as typo-free as possible. You can submit reports to
O'Reilly, or email them directly
to one of the book's co-authors (see the end of this page for current links):
Mark Lutz, or
David Ascher. Since the authors
maintain this page, emailing us directly is probably the most
efficient route. [Note to O'Reilly reprints folks: please
contact Mark or David when making changes; we may have a few
late-breaking tweaks not listed here.]
- (info) Page 13 and beyond, chapter 1, clarification:
Chapter 1 talks about using "your favorite text editor" to create
and save module files of Python code. But, as one reader pointed out,
if you're brand new to programming, you might not know what this means.
On UNIX or Linux, this may mean using something like "vi" or "emacs"; on
MS-Windows/DOS, it may mean using Notepad, the DOS "edit" command,
WordPad, MS-Word, etc. You can also use the text editors that are
part of the PythonWin port for Windows, and the IDLE package described
in an appendix (IDLE is portable between platforms). Plus whatever other
editor you may find on your machine--nedit, jot, etc.
- (info) Page 13 and beyond, chapter 1, clarification:
Another thing we seem to have taken for granted is how to start a
command-line session under MS-Windows, for running module files and
the interactive interpreter. (This may seem trivial to some, but at
least one reader has already asked.) To run a Python program in Windows
and see its output, you need to first start a "DOS box" to get the
"C:\" (or similar) command-line prompt. To start a DOS box, go to
your Start menu, and look for and select the "MS-DOS" icon in the
Programs submenu (the icon is labeled "Command Prompt"). At the prompt
in the DOS box, type "python file.py" to run file.py; you may need to
first run a "cd directory" command to go to the directory where
"file.py" was created. A few notes: there are other ways to run programs on
Windows (e.g., within the PythonWin or IDLE GUIs); for some ports you may
also need to run a ".bat" file to configure some settings (see chapter 1);
and you can get a similar command-line prompt under UNIX or Linux by
starting an "xterm" or "shell" box.
- (info) Page 33, end of first paragraph:
This may be obvious, is implied by the example, and is described
fully in chapter 3, but I'd like to underscore the notion of
variable evaluation for people new to programming.
change:
"; as usual, expression results are echoed back to us
at the interactive prompt:"
to:
"; variables are replaced with their values, and expression
results are echoed back to us:"
- (info) Page 35, paragraph 3: One reader suggested that
"__builtin__" should be changed to "__builtins__" (plural). It should
not, but we also use the plural "__builtins__" on page 217, and never
explain the distinction. In short, there is a single "__builtin__"
predefined module in the system (in the sys.modules table), and every
module namespace gets a predefined attribute called "__builtins__" which
references the single "__builtin__" module. By changing some of these
predefined attributes, you can customize the set of built-in names, and
hence limit access to the machine. So, each module has a "__builtins__"
which refers to the single "__builtin__", where built-in names live. But
you can get to them through "__builtins__" too, since it's just a link
back to "__builtin__". Can you see why we didn't want to explain this? ;-)
- (figure) Page 60, figure 2-2: There probably should be
4 cells in the dictionary object pointed to by D, not 3 (2 key:value
pairs). On the other hand, this is only a rough sketch.
- (typo) Page 108, last sentence, last paragraph:
change "assigns toast and eggs" to "assigns toast and ham". Those
are the formal argument names with defaults in the def header.
- (clarification) Page 110: One reader suggests that the
first bullet item would be clearer if it read: "In the call,
positional arguments must appear before keyword arguments." (TBD)
- (typo) Page 148, table 5-1, row 3, column 1:
Change "from mod import" to "from mod import *" (add the star).
- (font) Page 153, end of comment in example in mid page:
In "# self is the instance", the last two letters look
like they're in bold font; they shouldn't be.
- (info) Page 171, class PizzaRobot at bottom of page:
This isn't a bug, and doesn't need to be changed, but there is
really no reason for the PizzaRobot class to have an "__init__"
constructor method of its own; it works the same if "__init__"
is inherited from class Chef directly.
- (typo) Page 177, paragraph 2, sentence 2:
Change "...in each class that it lists in its header line."
to "...for each class that includes Lister in its header line.".
This is implied later in the section; the wording was broken
during production, but the original version wasn't very clear
either. While we're on this page, change the start of sentence
1 in paragraph 1 to read "As seen in the previous section..."
- (info) Page 199, footnote: Should also mention that
there is a short PDB debugger example at the end of chapter 8
in this book too.
- (typo/bug) Page 205, in Python code near end of the
"Why You Will Care" sidebar: Change one semicolon
to a colon, and delete the other.
change:
def dostuff(); # <- this is a syntax error
...
doLastThing(); # <- this is okay, but not needed
to:
def doStuff():
...
doLastThing()
- (typo) Page 205, sidebar, last paragraph, first
sentence: Change "there's no ned" to "there's no need". Ned
may or may not be able to help ;-).
- (font) We've found a bunch of places where
the "..." continuation prompt (printed by the interactive
command-line interpreter) is in bold font. That might make
it seem like the "..." is entered by the user. It isn't
(as we explain elsewhere), but to avoid confusion, these
should all be changed to non-bold. Places we've seen this:
- p. 76 (within 'a...b')
- p. 78 (4 lines)
- p. 88 (1 line)
- p. 89 (8 lines)
- p. 90 (8 lines)
- p. 107 (1 line)
- p. 105 (1 line)
- p. 117 (1 line)
- p. 118 (1 line)
- p. 119 (1 line)
- p. 120 (2 lines)
- p. 121 (1 line)
- (info) General remark: during production, all the
module file name labels were dropped. In the original draft,
a file's code was preceded by a label line of the form
"File: xxx.py", which made it more obvious where imported
code was coming from when an "import xxx" showed up later.
I haven't yet decided if this warrants a change, but there are
a few cases where it might help to make the file name more explicit.
This only happens in examples that appear after module files
are explained, so the relationship between an import and the
location/file of imported code should be obvious to readers.
Moreover, examples in the source-code
distribution are marked with the name of the file they should be put
in, if you're working along.
On the other hand, there are a few places where it may be clearer
if the file names were mentioned in the text, especially for
readers who open the book randomly to sections after the modules
chapter (e.g., p.178 runs a file called "testmixin.py", which
imports a "mytools.py", but neither of the preceding code
listings are labeled with their file name). To be decided.
- (typo) Page 220: Example of ord(c) should show
ord('A') value as 65.
- (typo) Page 220: Entry for "tuple(seq)" should say
"Returns the tuple version...", not "Returns the list version...".
- (typo) Page 224, line 3, word 5: "objects" should
be "object" ("A callable object ...").
- (typo) Page 234
change:
os.path.walk('..', test_walk, 'show'
to:
os.path.walk('..', test_walk, 'show')
- (typo) Page 236: Fix indentation of last code line
on right column in table 8-11 (not indented enough).
- (typo) Page 236: Fix indentation of last code line on
right column in table 8-12 for example for urlparse
(second line is indented too far, third line not enough)
- (typo/bug) Page 259, in example at top:
change:
os.system('/usr/bin/mail ... < %(tempfile)s' ... )
to:
os.system('/usr/bin/mail ... < %(tempfilename)s' ... )
- (typo/bug) Page 265, in the get_temperature function:
change:
stop = string.index(data,'°v;F',start-1)
to:
stop = string.index(data,'°F',start-1)
- (typo/bug) Page 276, Chapter 10 CGI example: seems to be
missing the initial "#!/usr/bin/python" line which is referenced in
the prose on page 279. This example also seems to be missing an
initial print statement in the bail() method, for the required
"Content-type" header line (see gush() and whimper()).
- (typo) Page 281: Delete space between "FormData." and
"__init__" in second text paragraph.
- (typo/bug) Page 288: "tkinter" should be "Tkinter"
change:
from tkinter import mainloop
to:
from Tkinter import mainloop
- (typo/bug) Page 290: It looks like we somehow dropped an
entire line from the source-code of the Tkinter browser example. Add
the following new line, after the current 6th line from the top in the
code listing:
self.listbox.bind('<ButtonRelease-1>', self.select)
indented the same as the "self.row = self.row + 1" on line 7.
This line is referred to on page 292 (and was "reprinted" there),
but it somehow was lost on the earlier page in the __init__ constructor.
- (typo) Page 292, near start of longest paragraph: Change
"self-select" to "self.select".
- (typo/bug) Page 293, extra paren in program
code near top of page:
change:
string.replace(labelstr, '\r'), '')
to
string.replace(labelstr, '\r', '')
- (info) Page 298, Chapter 10: The JPython grapher
example relies on the struct module,
which is only present in the newest JPython release.
(It imports the pickle module, which imports struct).
More details and a workaround for older JPython
releases will be posted here soon.
- (info)
Page 325, last column of last row of table B-1:
Change the contact point for the maintainer of the Python port
on VxWorks, Jeff Stearns, to read "mailto:jeffstearns@home.com".
Jeff says the majority of requests for info about Python on
VxWorks now come to him by way of this book, but the email
address in the book isn't very reliable.
- (typo/bug) Page 352, end of solution 4:
change:
def word(self, index):
return self.words[index]
to:
def word(self, index):
return self.words[index] # properly indented!
- (typo) Page 356, solution #2:
change:
print "Got comment from %(name)s, skipping printing." %
vars(data)
to:
print "Got comment from %(name)s, skipping printing." % \
vars(data)
- (typo) Page 356, solution #3:
change:
# code from existing program, up to
graphics.fillPolygon(xs, ys, len(xs))
to: (left aligned!)
# code from existing program, up to graphics.fillPolygon(xs, ys, len(xs))
- (typo) Page 365, index: Delete the "sys.path dictionary" entry
(it's a list, not a dictionary!), and add its page number (139) to the entry
for "sys.path" immediately above.