[Tutor] writing a program in Python
Michael Lange
klappnase at freenet.de
Tue Dec 30 19:55:17 EST 2003
On Tue, 30 Dec 2003 15:30:33 -0800 (PST)
Christopher Spears <cspears2002 at yahoo.com> wrote:
> I guess this is a stupid question, but I am going to
> ask anyway...
>
> How do you actually write a program in Python? I know
> how to use IDLE to manipulate data, but how do I write
> several lines of code that goes out and does stuff.
>
Hi Christopher!
You just have to write your program in any text editor (if your using IDLE select from the menu File --> New) and store it.
If your using windows you should store it with the ".py" extension, so you can run it from your file browser with a
double-click like any other program (you will see then a DOS box pop up every time you start your program;
if you want to avoid this use the extension ."pyw" instead of ".py" ).
On linux the ".py" extension is not necessarily required, however you will have to make the file you wrote
executable first ("chmod -v 755 path-to-your-file"). You can run it then with "python path-to-your-file"
(if you make the first line of your file:
#!/usr/bin/env python
you can run it like any other program without calling the python interpreter every time).
I hope this helped
Good luck
Michael
More information about the Tutor
mailing list