Kaydet (Commit) 5bba6c27 authored tarafından Ezio Melotti's avatar Ezio Melotti

Merge with 3.2.

...@@ -997,7 +997,7 @@ etc. are all supported. ...@@ -997,7 +997,7 @@ etc. are all supported.
required required
^^^^^^^^ ^^^^^^^^
In general, the argparse module assumes that flags like ``-f`` and ``--bar`` In general, the :mod:`argparse` module assumes that flags like ``-f`` and ``--bar``
indicate *optional* arguments, which can always be omitted at the command line. indicate *optional* arguments, which can always be omitted at the command line.
To make an option *required*, ``True`` can be specified for the ``required=`` To make an option *required*, ``True`` can be specified for the ``required=``
keyword argument to :meth:`add_argument`:: keyword argument to :meth:`add_argument`::
...@@ -1617,9 +1617,9 @@ Mutual exclusion ...@@ -1617,9 +1617,9 @@ Mutual exclusion
.. method:: add_mutually_exclusive_group(required=False) .. method:: add_mutually_exclusive_group(required=False)
Create a mutually exclusive group. argparse will make sure that only one of Create a mutually exclusive group. :mod:`argparse` will make sure that only
the arguments in the mutually exclusive group was present on the command one of the arguments in the mutually exclusive group was present on the
line:: command line::
>>> parser = argparse.ArgumentParser(prog='PROG') >>> parser = argparse.ArgumentParser(prog='PROG')
>>> group = parser.add_mutually_exclusive_group() >>> group = parser.add_mutually_exclusive_group()
...@@ -1786,14 +1786,14 @@ Exiting methods ...@@ -1786,14 +1786,14 @@ Exiting methods
Upgrading optparse code Upgrading optparse code
----------------------- -----------------------
Originally, the argparse module had attempted to maintain compatibility with Originally, the mod:`argparse` module had attempted to maintain compatibility
optparse. However, optparse was difficult to extend transparently, particularly with :mod:`optparse`. However, :mod:`optparse` was difficult to extend
with the changes required to support the new ``nargs=`` specifiers and better transparently, particularly with the changes required to support the new
usage messages. When most everything in optparse had either been copy-pasted ``nargs=`` specifiers and better usage messages. When most everything in
over or monkey-patched, it no longer seemed practical to try to maintain the :mod:`optparse` had either been copy-pasted over or monkey-patched, it no
backwards compatibility. longer seemed practical to try to maintain the backwards compatibility.
A partial upgrade path from optparse to argparse: A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
* Replace all ``add_option()`` calls with :meth:`ArgumentParser.add_argument` * Replace all ``add_option()`` calls with :meth:`ArgumentParser.add_argument`
calls. calls.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment