[Tutor] command line arguements
dman
dsh8290@rit.edu
Fri, 23 Nov 2001 11:41:25 -0500
On Fri, Nov 23, 2001 at 01:51:56AM -0500, Kirk Bailey wrote:
| OK, here ya go. Slightly deeper sorcery time.
...
| how does one tell a python program to pay attention to command line
| data? I can do this in a shell script, and a few other languages, but do
| not yet comprehend it in python.
$ cat args.py
import sys
print sys.argv
$ python args.py
['args.py']
$ python args.py a b c
['args.py', 'a', 'b', 'c']
$ python args.py abc def g
['args.py', 'abc', 'def', 'g']
$
Also check out the getopt module for parsing options (eg -o or
--option or --option=value or --option value).
-D