summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-01-09 09:33:09 (GMT)
committerGeorg Brandl <georg@python.org>2011-01-09 09:33:09 (GMT)
commit585bbb98a7dd9b27547d4802babf354609907386 (patch)
treee72e9a54bbd294f694093f9a1c889960fd070a24
parentcbb2e49c3cddd9c191b175877a91e73c5fdea47d (diff)
downloadcpython-585bbb98a7dd9b27547d4802babf354609907386.zip
cpython-585bbb98a7dd9b27547d4802babf354609907386.tar.gz
cpython-585bbb98a7dd9b27547d4802babf354609907386.tar.bz2
Merged revisions 87890 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87890 | georg.brandl | 2011-01-09 10:04:08 +0100 (So, 09 Jan 2011) | 1 line Wrap some long examples and signatures. ........
-rw-r--r--Doc/library/argparse.rst21
1 files changed, 14 insertions, 7 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 0ea8195..d149d7a 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -120,7 +120,9 @@ command-line args from :data:`sys.argv`.
ArgumentParser objects
----------------------
-.. class:: ArgumentParser([description], [epilog], [prog], [usage], [add_help], [argument_default], [parents], [prefix_chars], [conflict_handler], [formatter_class])
+.. class:: ArgumentParser([description], [epilog], [prog], [usage], [add_help], \
+ [argument_default], [parents], [prefix_chars], \
+ [conflict_handler], [formatter_class])
Create a new :class:`ArgumentParser` object. Each parameter has its own more
detailed description below, but in short they are:
@@ -563,7 +565,9 @@ your usage messages.
The add_argument() method
-------------------------
-.. method:: ArgumentParser.add_argument(name or flags..., [action], [nargs], [const], [default], [type], [choices], [required], [help], [metavar], [dest])
+.. method:: ArgumentParser.add_argument(name or flags..., [action], [nargs], \
+ [const], [default], [type], [choices], [required], \
+ [help], [metavar], [dest])
Define how a single command line argument should be parsed. Each parameter
has its own more detailed description below, but in short they are:
@@ -777,9 +781,11 @@ values are:
>>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
... default=sys.stdout)
>>> parser.parse_args(['input.txt', 'output.txt'])
- Namespace(infile=<open file 'input.txt', mode 'r' at 0x...>, outfile=<open file 'output.txt', mode 'w' at 0x...>)
+ Namespace(infile=<open file 'input.txt', mode 'r' at 0x...>,
+ outfile=<open file 'output.txt', mode 'w' at 0x...>)
>>> parser.parse_args([])
- Namespace(infile=<open file '<stdin>', mode 'r' at 0x...>, outfile=<open file '<stdout>', mode 'w' at 0x...>)
+ Namespace(infile=<open file '<stdin>', mode 'r' at 0x...>,
+ outfile=<open file '<stdout>', mode 'w' at 0x...>)
* ``'*'``. All command-line args present are gathered into a list. Note that
it generally doesn't make much sense to have more than one positional argument
@@ -1744,11 +1750,12 @@ backwards compatibility.
A partial upgrade path from optparse to argparse:
-* Replace all ``add_option()`` calls with :meth:`ArgumentParser.add_argument` calls.
+* Replace all ``add_option()`` calls with :meth:`ArgumentParser.add_argument`
+ calls.
* Replace ``options, args = parser.parse_args()`` with ``args =
- parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls for the
- positional arguments.
+ parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument`
+ calls for the positional arguments.
* Replace callback actions and the ``callback_*`` keyword arguments with
``type`` or ``action`` arguments.