[Tutor] (no subject)
alan.gauld at freenet.co.uk
Wed Sep 14 09:33:09 CEST 2005
>I am new to Python, about 1 day. And I downloaded from
> python.org Pythong2.4, it has the command line and
> junk. But what actuall program compiles the source of
> python into a program?
When you run a python script python compiles the source
internally before executing it. If your program imports
modules, the imported code gets converted into compiled
code and you will see it in the form of .pyc files.
Python works in a similar fashion to VB and Java in that
it executes compiled byte code, not native machine code.
The Python program has the same function as both the
Java compiler and JVM interpreter.
If you use Jython instead of Python you will find a separate
python compiler that produces true Java code that then
can be run under any JVM.
If you want to produce standalone windows executables
there are several tools available, the simplest and
most widely used being py2exe. This is not part of the
standard distribution however. Basically what all these
tools do is wrap the Python program and all of the
modules you use into one single executable file - so
its quite big and if you distribute several programs
you duplicate python with each one!! In this case
distributing the python scripts with a one-off version
of Python is a better option.
The included distutils package can simplify that process.
> And also, is Python capable of writing an OS?
Not really since python requires the python program to
be present in some form and it itself needs an underlying
OS. You could write an OS simulation as a learning
excercise but it would need a minimal OS underlying it.
Python is a high level programming language aimed at
developing applications with the minimum effort. If you
really need to twiddle the bits n' bytes you are better
off with C or assembler, just be prepared to write a
lot of code...
Author of the Learn to Program web tutor
More information about the Tutor