[Tutor] program closes straight away + python compiler?

alan.gauld@bt.com alan.gauld@bt.com
Mon, 21 Oct 2002 12:16:52 +0100


> When using a program i've written with python, 
> the window closes as soon as its finished its job, 

This should be in the Python FAQ, I must check sometime!

There are several options:
1) put a line like this at the end of your program:

raw_input('Hit Enter to quit')

Which will pause the window until you hit the enter key.

2) Run the program from a DOS prompt rather than double 
clicking. That way the window stays open.

3) Create a shortcut then adjust the properties so that 
it doesn't close on exit(its a checkbox somewhere...)

> Also, is there some sort of python compiler available 
> or similar so that I could make python programs 
> available to people without the python interpreter?

Likewise I hope this is in the FAQ....

There are several tools for doing this. On windows 
the most popular is py2exe. Be aware tho that what they 
really do is just bundle the python interpreter and 
any required libraries into an executable file. 
So if you distribute many scripts you wind up having 
lots of pythons installed which takes up more space 
than just giving out python once....

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld