"Kevin Rapley" <ke...@digikev.co.uk> wrote
The simplest way is to put a "shebang" line at the top of your
script
and then make them executable:
$ cat> myscript.py
What is the significance of this and how do I use it?
>>> cat > tryme1.py
Notice the difference in the prompt. A dollar sign is the generic
way of indicating a Unix shell prompt.
cat is a Unix command which catenates the output to a file, again
using
cat like this is a generic way of sayong create a file containing
whatever
follows cat. In practice you would use a text editor like vim or pico
etc.
means the python prompt. You are typing a Unix command into Python
which doesn't reciognise it, hence the error.
My apologies for not being explicit. I assumed since you were using
the shell to run sudo port install that you were an experienced Unix
shell user and would understand the significance of $.
(Incidentally % is the generic way of indicating a rioot user command,
so
% cat > mydfile
implies login as root (or use sudo) to type the command....)
Then use chmod +x to make it executable
$ chmod +x myscript.py
When I try to run this with one of my files I get the following
error:
>>> chmod +x tryme1.py
Same problem. chmod is the unix command to Change Mode of a file.
$ myscript.py
Alternatively you can just call python explicitly:
$ python myscript.py
I get a syntax error doing this too:
>>> python tryme1.py
And again, you type python on its own to start a Python interpreter
session.
You type, in Unix shell, python file.py to get Python to execute
file.py
You can find a box explaining some of this in my tutor in the Style
topic,
near the bottom...
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor