Python is an interpreted language, so you do not need to compile it; just to run it. As it happens, the standard version of python will compile it into "bytecode", like Java, etc., And save it (in .pyc files) and run it next time, saving time if you did not update the file since. If you updated the file, it will be automatically recompiled.
You can also run python with the -O flag, which will generate .pyo files instead of .pyc. I am not sure that this is of great importance. If speed is important, use psyco.
And yes, on Unix (including Linux, BSD, and Mac OS X, or in the unix shell on windows) you can use the shebang line at the top of the file so that the file starts automatically using python. On Windows, the equivalent is to link the .py files to the python.exe file, and then make sure the PATHEXT environment variable includes the .PY extension.
However, for Windows, you most likely want to write a GUI program in python (possibly using PyQT4 and ERIC4) that has a .pyw file as the main script and has a .pyw associated with pythonw (which comes with python on windows). This will allow you to run python scripts on windows, like other graphics programs. For publishing and distribution, you probably want to compile the executable using something like py2exe, as mentioned in others.
Lee B Sep 16 '09 at 17:44 2009-09-16 17:44
source share