[Tutor] Writing Scripts.
Alan Gauld
alan.gauld at btinternet.com
Wed Oct 20 18:56:38 CEST 2010
"Autumn Cutter" <autumnc90 at gmail.com> wrote
>I just started learning Python last night and I'm a little stuck on
>how to write a Python script.
> I'm using Python 2.5.0 on a Mac OS X 10.6.4.
To create the program you use any standard text editor - although one
that supports
programming will be better. So you can use any of the programs you
listed.
All you need to do is create a new file containg your python code and
save
it with a sensible name and end it in .py
So you could create a file called hello.py which contains the single
line:
print "Hello"
After you save it open the Terminal application and navigate to the
folder
where you saved the file. ( ISTR that you can do that by dragging a
folder
from Finder onto the Terminal... if I'm dreaming use the cd
command...)
Now type
python hello.py
at the Unix prompt to get the code to run. You should see hello
printed on screen.
Try that and if it doesn't work tell us what happened, including the
exact text of
any error messages you see.
There are better ways to run the programs once you get itall set up
properly
but for now we will be best to stick to basics!
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list