-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_line_args_2.6.py
More file actions
31 lines (22 loc) · 857 Bytes
/
cmd_line_args_2.6.py
File metadata and controls
31 lines (22 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
'''
cmd_line_args_2.6.py - Example of using optparse for command-line arguments
Note that this is deprecated in 2.7 in favour or argparse, a suspiciously similar
library.
Example calls:
python cmd_line_args_2.6.py --file=your_face
python cmd_line_args_2.6.py --file=your_face -q
python cmd_line_args_2.6.py --booboo=your_face
Author: Eric Saunders
March 2012
'''
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help="don't print status messages to stdout")
(options, args) = parser.parse_args()
print "Filename:", options.filename
print "Verbosity:", options.verbose