22===============================================================================
33
44.. module :: argparse
5- :synopsis: Command-line option and argument- parsing library.
5+ :synopsis: Command-line option and argument parsing library.
66..
moduleauthor ::
Steven Bethard <[email protected] > 77..
sectionauthor ::
Steven Bethard <[email protected] > 88
@@ -107,7 +107,7 @@ or the :func:`max` function if it was not.
107107Parsing arguments
108108^^^^^^^^^^^^^^^^^
109109
110- :class: `ArgumentParser ` parses args through the
110+ :class: `ArgumentParser ` parses arguments through the
111111:meth: `~ArgumentParser.parse_args ` method. This will inspect the command line,
112112convert each arg to the appropriate type and then invoke the appropriate action.
113113In most cases, this means a simple :class: `Namespace ` object will be built up from
@@ -118,7 +118,7 @@ attributes parsed out of the command line::
118118
119119In a script, :meth: `~ArgumentParser.parse_args ` will typically be called with no
120120arguments, and the :class: `ArgumentParser ` will automatically determine the
121- command-line args from :data: `sys.argv `.
121+ command-line arguments from :data: `sys.argv `.
122122
123123
124124ArgumentParser objects
@@ -669,11 +669,11 @@ be positional::
669669action
670670^^^^^^
671671
672- :class: `ArgumentParser ` objects associate command-line args with actions. These
673- actions can do just about anything with the command-line args associated with
672+ :class: `ArgumentParser ` objects associate command-line arguments with actions. These
673+ actions can do just about anything with the command-line arguments associated with
674674them, though most actions simply add an attribute to the object returned by
675675:meth: `~ArgumentParser.parse_args `. The ``action `` keyword argument specifies
676- how the command-line args should be handled. The supported actions are:
676+ how the command-line arguments should be handled. The supported actions are:
677677
678678* ``'store' `` - This just stores the argument's value. This is the default
679679 action. For example::
@@ -745,8 +745,8 @@ the Action API. The easiest way to do this is to extend
745745 :meth: `~ArgumentParser.parse_args `. Most actions add an attribute to this
746746 object.
747747
748- * ``values `` - The associated command-line args , with any type- conversions
749- applied. (Type- conversions are specified with the type _ keyword argument to
748+ * ``values `` - The associated command-line arguments , with any type conversions
749+ applied. (Type conversions are specified with the type _ keyword argument to
750750 :meth: `~ArgumentParser.add_argument `.
751751
752752* ``option_string `` - The option string that was used to invoke this action.
@@ -778,7 +778,7 @@ single action to be taken. The ``nargs`` keyword argument associates a
778778different number of command-line arguments with a single action. The supported
779779values are:
780780
781- * N (an integer). N args from the command line will be gathered together into a
781+ * N (an integer). N arguments from the command line will be gathered together into a
782782 list. For example::
783783
784784 >>> parser = argparse.ArgumentParser()
@@ -822,7 +822,7 @@ values are:
822822 Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
823823 outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)
824824
825- * ``'*' ``. All command-line args present are gathered into a list. Note that
825+ * ``'*' ``. All command-line arguments present are gathered into a list. Note that
826826 it generally doesn't make much sense to have more than one positional argument
827827 with ``nargs='*' ``, but multiple optional arguments with ``nargs='*' `` is
828828 possible. For example::
@@ -846,7 +846,7 @@ values are:
846846 usage: PROG [-h] foo [foo ...]
847847 PROG: error: too few arguments
848848
849- If the ``nargs `` keyword argument is not provided, the number of args consumed
849+ If the ``nargs `` keyword argument is not provided, the number of arguments consumed
850850is determined by the action _. Generally this means a single command-line arg
851851will be consumed and a single item (not a list) will be produced.
852852
@@ -864,7 +864,7 @@ the various :class:`ArgumentParser` actions. The two most common uses of it are
864864
865865* When :meth: `~ArgumentParser.add_argument ` is called with option strings
866866 (like ``-f `` or ``--foo ``) and ``nargs='?' ``. This creates an optional
867- argument that can be followed by zero or one command-line args .
867+ argument that can be followed by zero or one command-line arguments .
868868 When parsing the command line, if the option string is encountered with no
869869 command-line arg following it, the value of ``const `` will be assumed instead.
870870 See the nargs _ description for examples.
@@ -914,11 +914,11 @@ command-line argument was not present.::
914914type
915915^^^^
916916
917- By default, :class: `ArgumentParser ` objects read command-line args in as simple
917+ By default, :class: `ArgumentParser ` objects read command-line arguments in as simple
918918strings. However, quite often the command-line string should instead be
919919interpreted as another type, like a :class: `float ` or :class: `int `. The
920920``type `` keyword argument of :meth: `~ArgumentParser.add_argument ` allows any
921- necessary type-checking and type- conversions to be performed. Common built-in
921+ necessary type-checking and type conversions to be performed. Common built-in
922922types and functions can be used directly as the value of the ``type `` argument::
923923
924924 >>> parser = argparse.ArgumentParser()
@@ -938,7 +938,7 @@ writable file::
938938 Namespace(bar=<_io.TextIOWrapper name='out.txt' encoding='UTF-8'>)
939939
940940``type= `` can take any callable that takes a single string argument and returns
941- the type- converted value::
941+ the converted value::
942942
943943 >>> def perfect_square(string):
944944 ... value = int(string)
@@ -973,7 +973,7 @@ See the choices_ section for more details.
973973choices
974974^^^^^^^
975975
976- Some command-line args should be selected from a restricted set of values.
976+ Some command-line arguments should be selected from a restricted set of values.
977977These can be handled by passing a container object as the ``choices `` keyword
978978argument to :meth: `~ArgumentParser.add_argument `. When the command line is
979979parsed, arg values will be checked, and an error message will be displayed if
@@ -1331,7 +1331,7 @@ An error is produced for arguments that could produce more than one options.
13311331Beyond ``sys.argv ``
13321332^^^^^^^^^^^^^^^^^^^
13331333
1334- Sometimes it may be useful to have an ArgumentParser parse args other than those
1334+ Sometimes it may be useful to have an ArgumentParser parse arguments other than those
13351335of :data: `sys.argv `. This can be accomplished by passing a list of strings to
13361336:meth: `~ArgumentParser.parse_args `. This is useful for testing at the
13371337interactive prompt::
@@ -1559,7 +1559,7 @@ FileType objects
15591559
15601560 The :class: `FileType ` factory creates objects that can be passed to the type
15611561 argument of :meth: `ArgumentParser.add_argument `. Arguments that have
1562- :class: `FileType ` objects as their type will open command-line args as files
1562+ :class: `FileType ` objects as their type will open command-line arguments as files
15631563 with the requested modes and buffer sizes:
15641564
15651565 >>> parser = argparse.ArgumentParser()
@@ -1673,7 +1673,7 @@ Parser defaults
16731673.. method :: ArgumentParser.set_defaults(**kwargs)
16741674
16751675 Most of the time, the attributes of the object returned by :meth: `parse_args `
1676- will be fully determined by inspecting the command-line args and the argument
1676+ will be fully determined by inspecting the command-line arguments and the argument
16771677 actions. :meth: `set_defaults ` allows some additional
16781678 attributes that are determined without any inspection of the command line to
16791679 be added::
0 commit comments