Book Example Updates

We've found 4 examples in the book (and on the CD) that need to be updated. Three of the updates are required for non-backward-compatible changes in Python 1.4 (they still work fine under 1.3). The examples to be updated:

  1. /dbase/formgui.py (Tk StringVars can't be called)
  2. /lang/calcgui2.py (Tk StringVars can't be called)
  3. /gui/guimixin.py (ScrolledText options change)
  4. /other/tutor/func1.py (missing a comma in a tuple)

Example changes tar file

To fetch a tar file with just the updated examples, click here. Then do a "tar -xvf progdiff.tar" command to unpack the changed files on your machine.

Example diff listings


The following listings are 'diff' runs for all 4 examples to be changed.
In the listings, you'll see a series of entries that look like:

    XXXcYYY
    N  new line
    ---
    O  old line

where: 

    - the XXXcYYY gives the example's line number(s) to change
    - the "N" line gives the new contents (change to this)
    - the "O" line gives the old contents (change from this).  

See the errata page for more details about these 4 updates.




Changes for "formgui.py", example 12-2, page 394, errata #48

61c61 N self.keytext.set(key) # change key in main box --- O self.keytext(key) # change key in main box 66c66 N text.set(`item[field]`) # same fields? reuse form --- O text(`item[field]`) # same fields? reuse form 79c79 N text.set( `item[field]` ) --- O text( `item[field]` ) 88c88 N key = self.keytext.get() --- O key = self.keytext() 98c98 N item[field] = eval(text.get()) # convert back from string --- O item[field] = eval(text()) # convert back from string 100c100 N self.errorbox('Bad data: "%s" = "%s"' % (field, text.get())) --- O self.errorbox('Bad data: "%s" = "%s"' % (field, text())) 107c107 N self.keytext.set('?%d' % len(self.index)) # default key unless typed --- O self.keytext('?%d' % len(self.index)) # default key unless typed 109c109 N text.set('') --- O text('') 113c113 N target = key or self.keytext.get() # passed in, or entered --- O target = key or self.keytext() # passed in, or entered

Changes for "calcgui2.py", example 16-19, page 688, errata #46

21c21 N self.text.set("0") --- O self.text("0") 49c49 N self.text.set('0') --- O self.text('0') 53,55c53,55 N self.eval.shiftOpnd(self.text.get()) # last or only opnd N self.eval.closeall() # apply all optrs left N self.text.set(self.eval.popOpnd()) # need to pop: optr next? --- O self.eval.shiftOpnd(self.text()) # last or only opnd O self.eval.closeall() # apply all optrs left O self.text(self.eval.popOpnd()) # need to pop: optr next? 61c61 N self.text.set('(') # clear text next --- O self.text('(') # clear text next 64,66c64,66 N self.eval.shiftOpnd(self.text.get()) # last or only nested opnd N self.eval.close() # pop here too: optr next? N self.text.set(self.eval.popOpnd()) --- O self.eval.shiftOpnd(self.text()) # last or only nested opnd O self.eval.close() # pop here too: optr next? O self.text(self.eval.popOpnd()) 70c70 N self.text.set(char) # clears last value --- O self.text(char) # clears last value 72c72 N self.text.set(self.text.get() + char) # else append to opnd --- O self.text(self.text() + char) # else append to opnd 76c76 N self.eval.shiftOpnd(self.text.get()) # push opnd on left --- O self.eval.shiftOpnd(self.text()) # push opnd on left 78c78 N self.text.set(self.eval.topOpnd()) # push optr, show opnd|result --- O self.text(self.eval.topOpnd()) # push optr, show opnd|result 95c95 N self.text.set(value) # expression or statement --- O self.text(value) # expression or statement

Changes for "guimixin.py", example 11-17, page 331, errata #47

61c61 N text = ScrolledText(new, height=30, width=90); text.pack() --- O text = ScrolledText(new, {'height':30, 'width':90, Pack:{}}) #1.2

Changes for appendix E, page 834, 3rd line from bottom, errata #2

Note: the line numbers don't mean much here--it's an unlabeled code snippet. 17c17 N schedule = [ (firstFunction, ('Hello world!',)), (count, ([1,2,3], [2,4])) ] --- O schedule = [ (firstFunction, ('Hello world!')), (count, ([1,2,3], [2,4])) ]

Back to my homepage



[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz