diff options
author | Georg Brandl <georg@python.org> | 2006-11-23 09:55:10 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-11-23 09:55:10 +0000 |
commit | 0c55236d39c5c3066903ace1c28e6a88c4efa2d0 (patch) | |
tree | 85a7e881b2e3e814e159aadc406e097b5a2a484d | |
parent | 9ff1d394027c1ae08d15df149bb1ee5a62f566de (diff) | |
download | cpython-git-0c55236d39c5c3066903ace1c28e6a88c4efa2d0.tar.gz |
Bug #1601630: little improvement to getopt docs
(backport from rev. 52833)
-rw-r--r-- | Doc/lib/libgetopt.tex | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/lib/libgetopt.tex b/Doc/lib/libgetopt.tex index e8b16a31e2..b38fcd8dff 100644 --- a/Doc/lib/libgetopt.tex +++ b/Doc/lib/libgetopt.tex @@ -126,8 +126,9 @@ import getopt, sys def main(): try: opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) - except getopt.GetoptError: + except getopt.GetoptError, err: # print help information and exit: + print str(err) # will print something like "option -a not recognized" usage() sys.exit(2) output = None @@ -135,11 +136,13 @@ def main(): for o, a in opts: if o == "-v": verbose = True - if o in ("-h", "--help"): + elif o in ("-h", "--help"): usage() sys.exit() - if o in ("-o", "--output"): + elif o in ("-o", "--output"): output = a + else: + assert False, "unhandled option" # ... if __name__ == "__main__": |