[Tutor] Beginner @ python

Alan Gauld alan.gauld at blueyonder.co.uk
Sun Sep 14 13:58:08 EDT 2003


Ok, Silly questions here...:)

Nope not silly, in fact one of the most commonly asked beginners 
questions. So you are in good company.

> so far I haven't seen anything, that I'm aware of, that was 
> written for Windows in Python 

One of the great things about Python is that a program that runs 
on Windows will probably work on Linux or Macintosh and vice-versa.

> (i.e. I haven't seen any executable Windows programs *.exe). 
> Is that because people "port" programs over to the Microsoft OS 
> or does Python always need to have the interpreter installed 

The latter. Python is like Java and Visual Basic in that respect. 
It needs some support files to be present. It just so happens 
that Windows comes with the Java and Visual Basic interpreters 
already installed whereas you have to install Python yourself.

In fact even compiled programs (native .exe files) still need 
some support libraries before they will run (usually msvcrt.dll 
and mfc4xx.dll) but again these are provided with Windows.

Now some people don't like the idea of asking fols to install 
Python before being able to run programs so somebody has written 
a little program (called py2exe) that bundles the essential 
Python interpreter files with your program to form a .exe. 

The snag with this approach is that the .exe is much bigger 
than the .py file that you started with so if you have a 
lot of programs to distribute you wind up giving out lots 
of big files each with a copy of Python inside!

You pays your money and you makes your choice.

If you choose to install Python then the individual .py files 
can be run by just double clicking in windows explorewr as usual.
Usually this will result in a DOS window popping up and 
displaying the output. If it closes too quickly you can add 
a line like:

raw_input("Hit return to quit")

at the end so you can see what happened before the window closes.

Eventually you will start writing GUI programs oin Python and 
then you won't need that trick, but we'll wait till you get there 
before going any further! :-)

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list