[Tutor] A basic question

Alan Gauld alan.gauld at btinternet.com
Sun Sep 6 22:46:03 CEST 2009


"sharon" <dillyg23 at gmail.com> wrote

>I have been trying how to get a any python program to run by clicking on 
> the icon.  I keep reading on the internet  make it executable:
> 
> chmod a+x try_python.py

You do this in a console window, at a bash prompt.

You also need to add the "shebang" line at the top of the file.
That's a standard format comment line that Unix knows to look 
at to determine which interpreter to use to execute the script.
It's a Unix thing, not Python, which is why the tutorials don't say 
much about it, they assume you know Unix if you are using it.

> everytime.  If I then sent this try_python.py  to someone else with 
> Ubuntu would it run on their system?  

Yes provided they use chmod on it too.

You can find more about the chmod and shebang stuff 
in the Style topic off my tutorial inside the Note for Unix Users 
near the bottom.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list