[Tutor] running programs in python

Sheila King sheila@thinkspot.net
Mon, 25 Feb 2002 13:44:11 -0800

On Mon, 25 Feb 2002 15:11:35 -0600, "Gordon W. Ayers" <gayers7@cogeco.ca>
wrote about [Tutor] running programs in python:

> Hi
>    Here is a pretty stupid question. How do I run a program from the
> python command line? I have IDLE and Pythonwin which I don't have too
> much trouble with but I would like to know how to execute a program from
> the command line in a DOS shell.
>       As is probably very obvious I have just started to use python.
>       Thanks in advance for any help.

OK, sounds like you are on a windows machine. Probably, Python has
installed itself, with settings in the registry, so that it is in your
"path" for your computer, so it should be called from just about any

Try this:

Open a DOS window (Go to the "Start" menu, Programs, and find MS-DOS in the
list). Change your directory to one containing a python script.

C:> cd practice

and now at the command prompt type

C:\practice> python myscript.py

Where myscript.py is in the directory practice on the C: drive.

You could always do it from a different directory if you include the full
path to the script.

C:\otherdir> python c:\practice myscript.py

should work, too.


Sheila King

"When introducing your puppy to an adult cat,
restrain the puppy, not the cat." -- Gwen Bailey,
_The Perfect Puppy: How to Raise a Well-behaved Dog_