[Pythonmac-SIG] Python Basics

Bob Savage savageb@pacbell.net
Sun, 25 Jun 2000 10:49:10 -0700


on 6/23/00 11:28 AM, your friend wrote:

> hi again.i cant seem to run scripts that i written.i dont have a clue what
> to do to run it.im very new to programming.im just making very simple
> scripts like 1+1 and stuff.its hard to find how to run srcipt for the mac on
> the internet.thanx

Hi.

Yes, there is a shortage of information describing the differences involved
in running Python on a Mac. One good place to look, though, is in the old
messages of the MacPython mailing list
<http://www.python.org/sigs/pythonmac-sig/>.

Why don't you try this:

First, open the Python 1.5.2c1 folder in the finder. There are several
applications in this folder. The two main ones are PythonInterpreter, and
Python IDE. PythonInterpreter is the application that is like most
references on the net to using Python.

Second, Launch (double-click on) the PythonInterpreter. You should get a
window that looks like this:


Python 1.5.2c1 (#56, Apr 12 1999, 14:19:52)  [CW PPC w/GUSI w/MSL]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 


This is an interactive scripting environment, so to run the program:

1+1

all you need to do is type it in and hit enter.

Third, There is an **EXCELLENT** tutorial available at:

http://www.python.org/doc/current/tut/tut.html

Just remember that when they talk about the Python interpreter, they are
talking about having launched the PythonInterpreter application. If they
talk about writing a file, and launching it on the commandline, and
arguments, you can do that with the same application, but, again it is done
a little differently on the Mac.

Fourth, You can write a file in anything from SimpleText to ms word; just
make sure you save the file in TEXT ONLY (sometimes called ASCII) format.
Use the '.py' ending to the filename as they describe.

To launch it drag the script that you want to run onto the PythonInterpreter
icon, and let go. It works just as it would with another document that you
wanted to open with a particular application on the Mac.

(Fifth) However, you are liable to find that the Python IDE works better for
you. It takes care of some things for you, like it includes a text file
editor, but you can also have an Interpreter window open while you work on a
file. This is nice for testing little snippets in the Interpreter while
writing out a longer program. In fact there is even a way to run code that
you select in a text file and run that immediately. *And* it can be set so
that when you save the file, the finder knows that that file is to be
launched with the PythonInterpreter application, so all you have to do is
double-click on your file to run it. I highly recommend checking that out.

Best of luck, I think you'll find learning Python to be very interesting!

Bob