On Feb 8, 10:14 pm, David Malcolm <dmalc...@redhat.com> wrote: > On Mon, 2010-02-08 at 12:53 -0800, Andrej Mitrovic wrote: > > The book covers Python 2.x syntax. > > > You might have downloaded Python 3.1, which has different syntax then > > Python 2.x. From what I can tell, the first example on page 7 is ">>> > > print 1 + 1". > > > Try issuing this command: > > print(1 + 1) > > > If everything goes well, and you get '2' as the answer, then you're > > probably using Python 3.x. You will have to download the Python 2.x > > binaries from the Python website, install Python 2.x, and try the > > example from the book again. > > Sorry to nitpick; the main thrust of the above sounds correct, in that: > print 1 + 1 > works in Python 2 but fails in Python 3, but, a minor correction, note > that: > print(1+1) > does work in Python 2 as well as in Python 3; the parentheses are > treated (in the former) as denoting grouping of a subexpression, rather > than function invocation (in the latter): > > Python 2.6.2 (r262:71600, Jan 25 2010, 13:22:47) > [GCC 4.4.2 20100121 (Red Hat 4.4.2-28)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> > print(1+1) > > 2 > > This can be useful if you're trying to write short fragments of code > that work with both. > > Look at the startup message, or run this command, which should work on > both python2 and python3: > import sys; print(sys.version) > > Hope this is helpful > Dave
Oops, you're right. I'm used to Python 3 syntax so I'm only aware of some basic differences. :) -- http://mail.python.org/mailman/listinfo/python-list