Couple quick questions from a Python Noob

bruno modulix onurb at xiludom.gro
Thu Jul 21 04:59:45 EDT 2005


digitalsubjunctive at gmail.com wrote:

> Hey, I just started on Python and have a few questions I couldn't find
> answers to on the Python site or it's tutorial.
> 
> 1. I notice a few "compiled python" files (indicated by reddish snake
> icons), I thought Python didn't need to be compiled? This is my first
> venture into programming, but if it doesn't need to be compiled why
> compile it?

Just like Java, the Python interpreter runs python byte-code. The Python
compiler compile Python source code into Python byte-code. Now the
difference with Java is that you don't have to manually call the
compiler - the interpreter will do it for you if and when needed.

If you don't know what 'byte-code' is, it's just like a machine language
(op-codes and the like) for a processor that doesn't exists - in fact
this 'processor' is the interpreter (or 'Virtual Machine') itself.

The main purpose is to have something that execute faster than purely
interpreted languages (since parsing is already done), and is still
portable between platforms (which is not that much important with
Python, since we usually distribute the source files...).

> 2. What is a .pwy file?

(isn't that .pyw ?)
It's a Windows-only stuff that avoid the DOS shell window to be opened
when executing the script.

> 3. I want to save my first few programs as .exe files so I can show
> them off to all my leet friends. 

'.exe' files are Windows-specific. Python doesn't handle this out of the
box. But there are programs like py2exe (and others, don't remember
their name) that 'freeze' your script, the interpreter and all needed
librairies in a .exe.

HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list