This should be the easiest thing for me to do. It took me 20 mins. For someone with my experience, that's just not acceptable. Here's what happened.
The book I refer is called "Learning Python" by Mark Lutz. ( the 3rd edition )
He mentions there a very simple application. Here is the source,
print "Hello World"
print 2 ** 100
That looks easy enough. I typed it out in Notepad++ and tried running it from the editor. It didn't run. That meant 2 possiblities, either I had not configured Notepad++ correctly OR something was wrong with the python installed on my XP.
I decided to investigate the python angle. At my first attempt, I could not run the code even directly from the command line. -sigh- At least, now I knew where the problem was. I added the python intepretor to my environment variables but even then, things didn't work.
What I did get was a facinating error message. It was a syntax error at the first line.
That baffeled me. Some googling around and I found the issue. Turns out that I'm using Python 3.0 and the syntax I was using is for the older releases. This page,
http://docs.python.org/dev/3.0/whatsnew/3.0.html
explained it to me.
I got my program to work now. The new code looks like this,
print("Hello World")
print(2 ** 100)
I'm thinking of looking for a new book now. Something updated for Python 3.0. Let's see how I fare.
No comments:
Post a Comment