[Tutor] Simple Question About MacPython Interpreter

John McChesney-Young panis@pacbell.net
Wed, 07 Nov 2001 10:22:34 -0800


The welcome message for this list includes the statement:

>Feel free to ask even the most basic of
>questions -- that's what the list is for!

I'm going to take the list up on this offer with a humbling question;
humbling to me, that is.

I have a copy of Ivan Van Laningham's _Teach Yourself Python in 24 Hours_,
and after successfully navigating hour one, I discouragingly ran aground
partway into hour two. This will clearly show how much of a beginner I am.

I downloaded MacPython and was able to type commands into the interpreter
and have it "print" "Hello, World!" and do some basic arithmetic. However,
when I came to the section "Hello, Python!" on page 25 I came to a
stumbling block.

I followed the instructions as carefully as I could: I opened BBEdit Lite
(text editor), typed in the code specified:

print "Hello, World!"
print "Goodbye, World!"

saved the file with the name helloworld.py, double-clicked on the
interpreter to get a box of the sort I thought I needed, typed after the
prompt:

python helloworld.py

and got this error message:

>>> python helloworld.py
  File "<stdin>", line 1
    python helloworld.py
                     ^
SyntaxError: invalid syntax

Hmmm. Not good. I tried various fixes. First I wrote another file of code
in SimpleText on the off-chance that BBEdit was too rich for the
interpreter's taste. That didn't work either. I tried moving the
interpreter and the file into the same (new) folder. That didn't work. I
tried moving the files to the desktop, the hard drive, and the Python
folder in which the interpreter had been living (and to which I'd returned
it), and none of these helped.

Searching around on the Web I found a page which suggested dragging and
dropping. I tried dragging and dropping the icon for the code file onto the
menu strip icon for the interpreter. No dice.

Finally I stumbled on something that did work: I quit the interpreter and
dragged the file with the code in it onto the interpreter's icon. The
interpreter started up and ran, with a "<<terminated>>" title to the
window. I even experimented with a new file:

print 5**4

and as I had hoped would happen, it showed a window with:

625

(also with a <<terminated>> title to the window.)

Although this was gratifying, I still don't know why I can't type the
appropriate command into the box I get when I run the interpreter program
and have it do what it's supposed to. I expect that it's something
forehead-smackingly stupid that I'm either doing or not doing. Might
someone be so kind as to explain it to a Mac person whose "programming"
skills are limited to basic HTML?

Thank you very much!

John

*******
John McChesney-Young  ** panis@pacbell.net **  Berkeley, California, USA