PDA

View Full Version : executing python programs



kool_kat_os
December 23rd, 2007, 04:28 AM
I just wrote a program on python, how do I make it so I can make it like an actual program? (like firefox, thunderbird, yahoo messenger) or is that possible?

jflaker
December 23rd, 2007, 04:30 AM
Right click the file and go to the permissions tab and tick the "Allow executing file as program".

you should now be able to run it........

kool_kat_os
December 23rd, 2007, 04:31 AM
what extension do i save it as?

jflaker
December 23rd, 2007, 04:33 AM
It doesn't need to have an extension.....the header in the file (#!/bin/sh <--as an example) will tell Linux how to execute the program.

LaRoza
December 23rd, 2007, 04:33 AM
what extension do i save it as?

In Windows, .py is used for the association, but you don't really need a file extension. .py is the standard.

Mark it as executable.

Add this line to the top:



#! /usr/bin/python


You can run it like a regular program now.

kool_kat_os
December 23rd, 2007, 04:43 AM
uhhh,
Here is a simple thing i wrote with python on windows:


temprature = input("what is the temp of food?")
what is the temp of food?50
>>> if temprature > 50:
print "cooked"
else:
print "cook more"

cooked


What so i save it as and how do i execute in windows?

jflaker
December 23rd, 2007, 04:49 AM
for Windows, you would need to have Python installed.......given that it is installed......save the file as .py......Windows will associate the file with the proper programs and it will execute.

kool_kat_os
December 23rd, 2007, 04:51 AM
i saved it as .py, how do i execute it without python?

LaRoza
December 23rd, 2007, 06:48 AM
i saved it as .py, how do i execute it without python?

What?

You can't run a Python script without Python.

CptPicard
December 23rd, 2007, 07:02 AM
i saved it as .py, how do i execute it without python?

On Windows, check out py2exe, but... that's really not neccessarily the point you know... your Python programs are "real programs". Interpreted/VM languages are going to be more and more common in the future...

pmasiar
December 29th, 2007, 03:20 AM
On Windows, you can associate python.exe with .py extension, so clicking on file name in Windows Exploder will execute the file. It has same functionality as shebang line in Linux (#! /usr/bin/python) - to tell computer how to "understand" the code.

It will run in text mode (terminal), to make it pretty GUI as Firefox is, you need to work more on it. EasyGUI is the simplest GUI library AFAIK.