A few q's on python files.

J

Joseph Quigley

hiya,
i'm new to python (by a week) but am learning fast (that's what I like
about python--it's simplicity). I got disgusted with C and C++ (i was
learning) probably because of a bad copy of Visual C++ 6.0 that gave me errors.

I noticed that IDLE doesn't have an option to allow you to convert a .py or
pyc. file into an executable. Why? Am i wrong? Where can I find one (if I'm
right)?
 
L

Larry Bates

On windows there's py2exe which packs a python program
so that it can be distributed "like" and .exe, but Python
is a bytecode language (a la Java) so it is never actually
compiled into machine language. The .pyc files are the
bytecode that is actually executed. For C programmers
this takes some getting accustomed to.

Larry Bates
 
T

Tim Roberts

Joseph Quigley said:
i'm new to python (by a week) but am learning fast (that's what I like
about python--it's simplicity). I got disgusted with C and C++ (i was
learning) probably because of a bad copy of Visual C++ 6.0 that gave me errors.

I find that very hard to believe.
I noticed that IDLE doesn't have an option to allow you to convert a .py or
pyc. file into an executable. Why? Am i wrong? Where can I find one (if I'm
right)?

Like VB6 and Perl, Python is interpreted, not compiled. You don't compile
it into an .exe. You pass the script to the python.exe interpreter, where
it is executed.

There are packages (like py2exe) that can convert your script into an
executable, but they are essentially installers. They package your script,
and all the scripts and libraries it needs, into a single file along with
the interpreter. When the .exe is executed, it extracts the interpreter
and the scripts into a temp directory, and fires up the interpreter.
 
P

Peter Hansen

Tim said:
There are packages (like py2exe) that can convert your script into an
executable, but they are essentially installers. They package your script,
and all the scripts and libraries it needs, into a single file along with
the interpreter. When the .exe is executed, it extracts the interpreter
and the scripts into a temp directory, and fires up the interpreter.

Correction: py2exe doesn't really do that at all. At least,
not any of the "single file" or "extracting" stuff.

Py2exe packages all the Python bytecode into a single zip
file (library.zip) and also includes all .pyd and .dll
files required to run the program, along with a stub
..exe file which instantiates an interpreter (from pythonXX.dll)
and runs the main script.

Installers such as InnoSetup are what you use to do the
"single file" stuff, and when you run them they do the
usual Windows installer stuff like extracting files to the
installation directory, creating icons, etc.

Finally there are tools (names don't come to mind since I don't
use them, but they're easy to find) which *can* do that
"extract to temporary directory" thing rather than the InnoSetup
type of installer, but they're relatively rarely used I think.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,221
Messages
2,571,133
Members
47,747
Latest member
swapote

Latest Threads

Top