Awful book warning: How to think like a (Python) programmer - non-working examples

Robert Kern robert.kern at gmail.com
Mon Feb 8 15:52:20 EST 2010


On 2010-02-08 14:36 PM, Dave Peterson wrote:
> Page 7: Very first example doesn't compile: syntax error
> Pate 11: 2nd example: syntax error
> Page 12, printing digits: syntax error
> Page 13, printing a number: syntax error
> page 14, statements: syntax error

This book was written for the 2.x versions of Python. Are you using Python 3.1? 
Python changed some of its syntax for version 3.0, notably

   print "Hello, world!"

becomes

   print("Hello, world!")

This accounts for all of the SyntaxErrors that you are seeing. The examples 
aren't broken for the version of Python it is teaching.

You may want to try _Dive Into Python 3_ to learn about Python 3 in particular:

   http://diveintopython3.org/

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list