summaryrefslogtreecommitdiffstats
path: root/Doc/library/optparse.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-04 22:00:42 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-10-04 22:00:42 (GMT)
commite5384b08861edde56d0b280f5993766d309ab4d0 (patch)
treeeb00d3d112d67d3300bbf23dec974c6994be07ea /Doc/library/optparse.rst
parent7d8d9a588c497c627b62bd7fa79bc6fef693aa5f (diff)
downloadcpython-e5384b08861edde56d0b280f5993766d309ab4d0.zip
cpython-e5384b08861edde56d0b280f5993766d309ab4d0.tar.gz
cpython-e5384b08861edde56d0b280f5993766d309ab4d0.tar.bz2
Merged revisions 66670,66681,66688,66696-66699 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66670 | georg.brandl | 2008-09-28 15:01:36 -0500 (Sun, 28 Sep 2008) | 2 lines Don't show version in title. ........ r66681 | georg.brandl | 2008-09-29 11:51:35 -0500 (Mon, 29 Sep 2008) | 2 lines Update nasm location. ........ r66688 | jesse.noller | 2008-09-29 19:15:45 -0500 (Mon, 29 Sep 2008) | 2 lines issue3770: if SEM_OPEN is 0, disable the mp.synchronize module, rev. Nick Coghlan, Damien Miller ........ r66696 | andrew.kuchling | 2008-09-30 07:31:07 -0500 (Tue, 30 Sep 2008) | 1 line Edits, and add markup ........ r66697 | andrew.kuchling | 2008-09-30 08:00:34 -0500 (Tue, 30 Sep 2008) | 1 line Markup fix ........ r66698 | andrew.kuchling | 2008-09-30 08:00:51 -0500 (Tue, 30 Sep 2008) | 1 line Markup fixes ........ r66699 | andrew.kuchling | 2008-09-30 08:01:46 -0500 (Tue, 30 Sep 2008) | 1 line Markup fixes. (optparse.rst probably needs an entire revision pass.) ........
Diffstat (limited to 'Doc/library/optparse.rst')
-rw-r--r--Doc/library/optparse.rst28
1 files changed, 14 insertions, 14 deletions
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst
index 4936e7d..3d8b43c 100644
--- a/Doc/library/optparse.rst
+++ b/Doc/library/optparse.rst
@@ -597,7 +597,7 @@ There are two broad classes of errors that :mod:`optparse` has to worry about:
programmer errors and user errors. Programmer errors are usually erroneous
calls to ``parser.add_option()``, e.g. invalid option strings, unknown option
attributes, missing option attributes, etc. These are dealt with in the usual
-way: raise an exception (either ``optparse.OptionError`` or ``TypeError``) and
+way: raise an exception (either ``optparse.OptionError`` or :exc:`TypeError`) and
let the program crash.
Handling user errors is much more important, since they are guaranteed to happen
@@ -794,10 +794,10 @@ And to define an option with only a long option string::
The keyword arguments define attributes of the new Option object. The most
important option attribute is :attr:`action`, and it largely determines which
other attributes are relevant or required. If you pass irrelevant option
-attributes, or fail to pass required ones, :mod:`optparse` raises an OptionError
-exception explaining your mistake.
+attributes, or fail to pass required ones, :mod:`optparse` raises an
+:exc:`OptionError` exception explaining your mistake.
-An options's *action* determines what :mod:`optparse` does when it encounters
+An option's *action* determines what :mod:`optparse` does when it encounters
this option on the command-line. The standard option actions hard-coded into
:mod:`optparse` are:
@@ -1054,7 +1054,7 @@ Option attributes
The following option attributes may be passed as keyword arguments to
``parser.add_option()``. If you pass an option attribute that is not relevant
to a particular option, or fail to pass a required option attribute,
-:mod:`optparse` raises OptionError.
+:mod:`optparse` raises :exc:`OptionError`.
* :attr:`action` (default: ``"store"``)
@@ -1147,7 +1147,7 @@ error message.
``choice`` options are a subtype of ``string`` options. The ``choices`` option
attribute (a sequence of strings) defines the set of allowed option arguments.
``optparse.check_choice()`` compares user-supplied option arguments against this
-master list and raises OptionValueError if an invalid string is given.
+master list and raises :exc:`OptionValueError` if an invalid string is given.
.. _optparse-parsing-arguments:
@@ -1220,10 +1220,10 @@ OptionParser provides several methods to help you out:
(e.g., ``"-q"`` or ``"--verbose"``).
``remove_option(opt_str)``
- If the OptionParser has an option corresponding to ``opt_str``, that option is
+ If the :class:`OptionParser` has an option corresponding to ``opt_str``, that option is
removed. If that option provided any other option strings, all of those option
strings become invalid. If ``opt_str`` does not occur in any option belonging to
- this OptionParser, raises ValueError.
+ this :class:`OptionParser`, raises :exc:`ValueError`.
.. _optparse-conflicts-between-options:
@@ -1254,13 +1254,13 @@ or with a separate call::
The available conflict handlers are:
``error`` (default)
- assume option conflicts are a programming error and raise OptionConflictError
+ assume option conflicts are a programming error and raise :exc:`OptionConflictError`
``resolve``
resolve option conflicts intelligently (see below)
-As an example, let's define an OptionParser that resolves conflicts
+As an example, let's define an :class:`OptionParser` that resolves conflicts
intelligently and add conflicting options to it::
parser = OptionParser(conflict_handler="resolve")
@@ -1490,7 +1490,7 @@ where
Raising errors in a callback
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-The callback function should raise OptionValueError if there are any problems
+The callback function should raise :exc:`OptionValueError` if there are any problems
with the option or its argument(s). :mod:`optparse` catches this and terminates
the program, printing the error message you supply to stderr. Your message
should be clear, concise, accurate, and mention the option at fault. Otherwise,
@@ -1691,9 +1691,9 @@ type-checking function will wind up in the OptionValues instance returned by
:meth:`OptionParser.parse_args`, or be passed to a callback as the ``value``
parameter.
-Your type-checking function should raise OptionValueError if it encounters any
-problems. OptionValueError takes a single string argument, which is passed
-as-is to OptionParser's :meth:`error` method, which in turn prepends the program
+Your type-checking function should raise :exc:`OptionValueError` if it encounters any
+problems. :exc:`OptionValueError` takes a single string argument, which is passed
+as-is to :class:`OptionParser`'s :meth:`error` method, which in turn prepends the program
name and the string ``"error:"`` and prints everything to stderr before
terminating the process.