[Tutor] Running the programs

D-Man dsh8290@rit.edu
Wed, 14 Feb 2001 17:10:26 -0500

On Wed, Feb 14, 2001 at 04:23:00PM -0500, Christopher Bemis wrote:
|    I am learning Python with"Learn Python in 24 hours", and am getting
|    quite a good grasp of the programming aspect....However here's my
|    problem........With all the sample progs that I've written I've used
|    Notepad as my editor....I save them as text as script.py.....but when
|    I try to run them I can't. I've tried Start/Run/.....py and I get a
|    flash of a DOS box. I try command prompt and it won't go at
|    all.....I'm running Win98Se....Is my DOS file path screwed up or is
|    there something else I need....I have Python2.0....or maybe I need a
|    new DOS prompt....how do I get one? Help Please  

People having trouble figuring out how to run scripts make me feel old
-- they must not have used MS-DOS before the days of MS Windows came
about.  (Don't feel so bad, lots of people have this problem)

By default, Windows will close the DOS box when the app is done.  One
workaround is to put the following line at the end of your program.
Then it won't be done until you say it is ;-).

raw_input( "Press enter to quit." )

Since you get a flash when you try Start->Run that means Windows has
the association correct to run a .py file.  (Unless you get a weird
error in the DOS box, but you can't see it anyways...)

There are a few things you can do if you want to run scripts from the

a)	Add c:\python20 (or whatever it is) to your PATH environment
variable.  This can be done in several ways :
	1)	type  set PATH %PATH%;c:\python20   when you start up
		a DOS box

	2)	append  set PATH %PATH%;c:\python20 to the end of your
		c:\autoexec.bat, then reboot ;-)  This will put python
		in the path for all DOS boxes you open

b)	Type the full path to python every time you run it (
	C:\myprog> c:\python20\python myscript.py )  =p

c)	Add a script (batch file) to a directory that is in the path,
	this script will run python with the full path and pass it any
	arguments you give

	-------- python.bat --------
	c:\python20\python %1 %2 %3 %4 %5 %6 %7 %8 %9

My preference is (c).  Actually, I use the bash shell provided by
cygwin (I really prefer Linux, but ...) and put similar scripts in
~/bin.  Bash is a much more powerful, convenient, and useful shell
than DOS provides. (FYI an example script :

	----------- ~/bin/python -------------

	//c/python20/python $*

As for your editor, notepad works but lacks the many conveniences of a
"real" editor.  I like gvim the best (www.vim.org) but it takes a
while to learn all of the commands.  There are other editors (and
IDEs) for windows.  I would strongly recommend finding one that you
like.  Some of the features I really like include :
	o autoindenting (and convenient re-indenting)
	o syntax highlighting
	o text wrapping (for long blocks of comments)
	o regex search and replace
	o rapid cursor movement


BTW	I'm not trying to start a flame war here about shells and
	editors, just providing some FYI