Newbie question about running scripts

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Sat Oct 6 01:23:31 EDT 2001


----- Original Message ----- 
From: "Lenny" <lenpfe at fastol.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Friday, October 05, 2001 11:47 PM
Subject: Newbie question about running scripts


> I have just begun reading and experimenting with the tutorials from
> the python website. I have programmed years ago with BASIC and COBOL,
> so I am not completely in the dark. The problem I am having is related
> to how scripts are handled by the interpretor. The tutorial says that
> I must set up the PATH in the registry but does not tell me how.

Not in the registry for Win95/98... in the autoexec.bat file:

    set PATH=c:\windows;c:\windows\command;c:\python22

for example (your PATH may vary).

BTW you should usually tell us exactly what version of Windows (or other 
OS) you are using.

> I
> looked in the registry and it appears that the install of Python 2.2
> took care of this for me. I saved a script that I wrote, using
> wordpad, as a .py file and it saved it with no problem. 

WORDPAD is not an ideal programming editor.  NOTEPAD would be better, or
anything else that doesn't have to be told to save as plain text.  I am
a VIM user but I wouldn't recommend it to someone not already familiar
with vi.

> The tutorial
> then said to go to the Windows command prompt. I am assuming this
> means the RUN function from the Start button options. 

No.  This means command.com (for Win9x) or cmd.exe (for WinNT/2K/XP).

Do Start, Run, type "command" or "cmd" (without the quotes) and press 
ENTER.

> When I type
> "python filename.py" in the RUN box and hit OK, I see a black box pop
> up on the screen for a fraction of a second. Not even long enough for
> me to read what it says.

This is because, when run from Start, Run command line programs run to 
completion or abort and the window is folded up immediately.  Do as shown
above and you can see the messages.

> My questions are:
> 1.)  Do I have to save my scripts to a certain folder that Python
> created for me or one I make for them?

No.  If you are using WinMe, Win2K, or WinXP you can add Python to the 
PATHEXT environment variable, allowing you to omit the reference to
python at the start of the command line; in other words,

    python myscript.py

would become 

    myscript

at the prompt.  If you do this, you must put your scripts in some folder
which is in the PATH given in autoexec.bat (or in the System Properties
for Me/NT/2K/XP); you could create a C:\UTIL folder as I do and add it to
the path, then put your scripts there.
 
> 2.)  Do I have to change something in the registry about the PATH even
> though Python appears to have a Python Path entry already in the
> memory?

Explained above.
 
> 3.)  Is the RUN window the window they mean as the "Command Prompt
> Window"?

No, as given above.
 
> I hate to bother everyone in this group with my trivial questions but
> I am looking forward to learn more about this language but I feel as
> though I am at a road block in my learning.

Most scripting languages under Windows follow these sort of rules, with
the possible exception of languages connected to the Windows Scripting
Host, which I don't know enough about to comment on.

> Does anyone suggest a certain online tutorial or other learning
> method.

I printed the entire library reference, language tutorial and language
reference (for the old 1.5.2 version) when I was learning Python...
but I was already an experienced C programmer, so perhaps this would
not be efficient for you.

> Thank you very much for taking the time to read my questions. I
> greatly appreciate your help and cooperation with this matter.
> 
> Thank You,
>
> Lenny

You're welcome,

Chris






More information about the Python-list mailing list