diff options
author | Raymond Hettinger <python@rcn.com> | 2003-04-29 04:35:36 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-04-29 04:35:36 (GMT) |
commit | 6e887bb05fe619448e33a429e226ad0a5b5c7a8a (patch) | |
tree | 900577f8b91975555c3d4ea7550348410f29b13e | |
parent | a2f8737faf02c49b0b98a2d789b1cd7537a36bbe (diff) | |
download | cpython-6e887bb05fe619448e33a429e226ad0a5b5c7a8a.zip cpython-6e887bb05fe619448e33a429e226ad0a5b5c7a8a.tar.gz cpython-6e887bb05fe619448e33a429e226ad0a5b5c7a8a.tar.bz2 |
SF bug #729096: getopt online documentation example improvement
A newbie found it difficult to translate the exampe into a
case that used only short options or long options but not both.
He tried to shorten the tuple search but forgot the trailing comma,
The appropriate pattern is an equality check.
Revised the example to point him in the right direction.
Backport candidate.
-rw-r--r-- | Doc/lib/libgetopt.tex | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Doc/lib/libgetopt.tex b/Doc/lib/libgetopt.tex index 49e6e03..558aafa 100644 --- a/Doc/lib/libgetopt.tex +++ b/Doc/lib/libgetopt.tex @@ -123,13 +123,16 @@ import getopt, sys def main(): try: - opts, args = getopt.getopt(sys.argv[1:], "ho:", ["help", "output="]) + opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) except getopt.GetoptError: # print help information and exit: usage() sys.exit(2) output = None + verbose = False for o, a in opts: + if o == "-v": + verbose = True if o in ("-h", "--help"): usage() sys.exit() |