This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: optparser example in optparse documentation is broken
Type: Stage:
Components: Documentation Versions: Python 3.0, Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: MLModel, georg.brandl
Priority: normal Keywords:

Created on 2009-09-12 02:12 by MLModel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg92530 - (view) Author: Mitchell Model (MLModel) Date: 2009-09-12 02:12
The help example in the middle of the optparse library documentation is
broken. The code reads:

parser = OptionParser()
parser.add_option("-h", "--help", action="help"),
parser.add_option("-v", action="store_true", dest="verbose",
                  help="Be moderately verbose")
parser.add_option("--file", dest="filename",
                  help="Input file to read data from"),

The result of executing this code is:

optparse.OptionConflictError: option -h/--help: conflicting option
string(s): -h, --help

I see that the documentation says that normally help is added
automatically so you don't need to do it, but doing so shouldn't break
especially since the example shows doing it.

Also, the trailing commas on two of the lines are weird and should be
removed.
msg92531 - (view) Author: Mitchell Model (MLModel) Date: 2009-09-12 02:18
There are other places on the same page with weird trailing commas that
should be removed. I think they all follow right parentheses.
msg92685 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-16 13:11
Fixed (by adding the add_help_option=False argument to OptionParser) in
r74824.
History
Date User Action Args
2022-04-11 14:56:52adminsetgithub: 51141
2009-09-16 13:11:13georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg92685
2009-09-12 02:18:11MLModelsetmessages: + msg92531
2009-09-12 02:12:58MLModelcreate