Executing programs

From Training Material
Revision as of 20:43, 5 February 2013 by Kristian Rother (talk | contribs) (→‎Starting programs on Windows)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Starting programs on Windows

Often, it is useful to use a Batch file to start a Python program on Windows. To do so, create an empty file with the ending .bat (Save as.. in IDLE), and write into it:

C:\Python26\python.exe my_script.py

Using command-line options

You can pass options to your program in the batch file. To interpret the options, the sys module contains a list of arguments sys.argv. Note that the first argument is always the name of the program.

import sys
print sys.argv