[Python-checkins] r52834 - python/branches/release25-maint/Doc/lib/libgetopt.tex

georg.brandl python-checkins at python.org
Thu Nov 23 10:55:10 CET 2006


Author: georg.brandl
Date: Thu Nov 23 10:55:10 2006
New Revision: 52834
Modified:
 python/branches/release25-maint/Doc/lib/libgetopt.tex
Log:
Bug #1601630: little improvement to getopt docs
 (backport from rev. 52833)
Modified: python/branches/release25-maint/Doc/lib/libgetopt.tex
==============================================================================
--- python/branches/release25-maint/Doc/lib/libgetopt.tex	(original)
+++ python/branches/release25-maint/Doc/lib/libgetopt.tex	Thu Nov 23 10:55:10 2006
@@ -126,8 +126,9 @@
 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 @@
 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__":


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /