summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-11-23 09:55:07 (GMT)
committerGeorg Brandl <georg@python.org>2006-11-23 09:55:07 (GMT)
commit3f969022c675c2f30258846f1ae44d8de9aa7312 (patch)
tree7392bec650002e62197dca2531edccd2866e6141
parent39b8b6afb52d3e1a0e52cd8f15f6b0d3210e5d6e (diff)
downloadcpython-3f969022c675c2f30258846f1ae44d8de9aa7312.zip
cpython-3f969022c675c2f30258846f1ae44d8de9aa7312.tar.gz
cpython-3f969022c675c2f30258846f1ae44d8de9aa7312.tar.bz2
Bug #1601630: little improvement to getopt docs
-rw-r--r--Doc/lib/libgetopt.tex9
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/lib/libgetopt.tex b/Doc/lib/libgetopt.tex
index e8b16a3..b38fcd8 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__":