Newbie Question

Raseliarison nirinA nirina at mail.blueline.mg
Tue May 27 12:23:58 EDT 2003


"M5B" wrote:

> I just started with Python, and have read through several books on the
> language. I installed Python 2.0 and PythonWin32.
>

first i recommend you get the latest Python released at:
http://www.python.org

> In all of the things that I have read there does not seem to be a clear
> explanation of how to save a program to disk,

you save a Python program like any files, for example, like a text file, but
with  .py extension.

> or how to retrieve it either to
> run or to work on further at a later time.
>

to use a Python program at a shell prompt, change to the directory where you
saved it
    cd the/program/directory
and execute it with:
    python theprogram.py

or if you are in a Python interpreter:
  >>> import os
  >>> os.chdir('the/program/directory')
  >>> execfile('theprogram.py')

> When I simply try to save the program, it fails to show up in the folder
> to
> which I thought I had saved it. When I try to retrieve it, it's not there.

maybe you saved your file in another directory or you failed to save it.
send to the list the traceback and error you encounter.

> On
> one occasion it somehow got stored (correctly, I can only assume) but when
> I
> try to open it, it's not there, and when I click on its icon I get only a
> brief
> flash on a black screen, then nothing.
>
> When am I doing wrong? Better, what should I be doing right? Help!

the machine executes your program so fast that all you can perceive is the
flash black screen.
if you want your program waiting for a return-key press, add the following
code at the end of your program:

raw_input('press return to exit')

or to halt the program for 5 secondes, add this:

import time
time.sleep(5)

hope this helps,
nirinA










More information about the Python-list mailing list