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
@@ -650,11 +650,11 @@ be positional::
650650action
651651^^^^^^
652652
653- :class: `ArgumentParser ` objects associate command-line args with actions. These
654- actions can do just about anything with the command-line args associated with
653+ :class: `ArgumentParser ` objects associate command-line arguments with actions. These
654+ actions can do just about anything with the command-line arguments associated with
655655them, though most actions simply add an attribute to the object returned by
656656:meth: `~ArgumentParser.parse_args `. The ``action `` keyword argument specifies
657- how the command-line args should be handled. The supported actions are:
657+ how the command-line arguments should be handled. The supported actions are:
658658
659659* ``'store' `` - This just stores the argument's value. This is the default
660660 action. For example::
@@ -726,8 +726,8 @@ the Action API. The easiest way to do this is to extend
726726 :meth: `~ArgumentParser.parse_args `. Most actions add an attribute to this
727727 object.
728728
729- * ``values `` - The associated command-line args , with any type- conversions
730- applied. (Type- conversions are specified with the type _ keyword argument to
729+ * ``values `` - The associated command-line arguments , with any type conversions
730+ applied. (Type conversions are specified with the type _ keyword argument to
731731 :meth: `~ArgumentParser.add_argument `.
732732
733733* ``option_string `` - The option string that was used to invoke this action.
@@ -759,7 +759,7 @@ single action to be taken. The ``nargs`` keyword argument associates a
759759different number of command-line arguments with a single action. The supported
760760values are:
761761
762- * N (an integer). N args from the command line will be gathered together into a
762+ * N (an integer). N arguments from the command line will be gathered together into a
763763 list. For example::
764764
765765 >>> parser = argparse.ArgumentParser()
@@ -803,7 +803,7 @@ values are:
803803 Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
804804 outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)
805805
806- * ``'*' ``. All command-line args present are gathered into a list. Note that
806+ * ``'*' ``. All command-line arguments present are gathered into a list. Note that
807807 it generally doesn't make much sense to have more than one positional argument
808808 with ``nargs='*' ``, but multiple optional arguments with ``nargs='*' `` is
809809 possible. For example::
@@ -827,7 +827,7 @@ values are:
827827 usage: PROG [-h] foo [foo ...]
828828 PROG: error: too few arguments
829829
830- If the ``nargs `` keyword argument is not provided, the number of args consumed
830+ If the ``nargs `` keyword argument is not provided, the number of arguments consumed
831831is determined by the action _. Generally this means a single command-line arg
832832will be consumed and a single item (not a list) will be produced.
833833
@@ -845,7 +845,7 @@ the various :class:`ArgumentParser` actions. The two most common uses of it are
845845
846846* When :meth: `~ArgumentParser.add_argument ` is called with option strings
847847 (like ``-f `` or ``--foo ``) and ``nargs='?' ``. This creates an optional
848- argument that can be followed by zero or one command-line args .
848+ argument that can be followed by zero or one command-line arguments .
849849 When parsing the command line, if the option string is encountered with no
850850 command-line arg following it, the value of ``const `` will be assumed instead.
851851 See the nargs _ description for examples.
@@ -895,11 +895,11 @@ command-line argument was not present.::
895895type
896896^^^^
897897
898- By default, :class: `ArgumentParser ` objects read command-line args in as simple
898+ By default, :class: `ArgumentParser ` objects read command-line arguments in as simple
899899strings. However, quite often the command-line string should instead be
900900interpreted as another type, like a :class: `float ` or :class: `int `. The
901901``type `` keyword argument of :meth: `~ArgumentParser.add_argument ` allows any
902- necessary type-checking and type- conversions to be performed. Common built-in
902+ necessary type-checking and type conversions to be performed. Common built-in
903903types and functions can be used directly as the value of the ``type `` argument::
904904
905905 >>> parser = argparse.ArgumentParser()
@@ -919,7 +919,7 @@ writable file::
919919 Namespace(bar=<_io.TextIOWrapper name='out.txt' encoding='UTF-8'>)
920920
921921``type= `` can take any callable that takes a single string argument and returns
922- the type- converted value::
922+ the converted value::
923923
924924 >>> def perfect_square(string):
925925 ... value = int(string)
@@ -954,7 +954,7 @@ See the choices_ section for more details.
954954choices
955955^^^^^^^
956956
957- Some command-line args should be selected from a restricted set of values.
957+ Some command-line arguments should be selected from a restricted set of values.
958958These can be handled by passing a container object as the ``choices `` keyword
959959argument to :meth: `~ArgumentParser.add_argument `. When the command line is
960960parsed, arg values will be checked, and an error message will be displayed if
@@ -1312,7 +1312,7 @@ An error is produced for arguments that could produce more than one options.
13121312Beyond ``sys.argv ``
13131313^^^^^^^^^^^^^^^^^^^
13141314
1315- Sometimes it may be useful to have an ArgumentParser parse args other than those
1315+ Sometimes it may be useful to have an ArgumentParser parse arguments other than those
13161316of :data: `sys.argv `. This can be accomplished by passing a list of strings to
13171317:meth: `~ArgumentParser.parse_args `. This is useful for testing at the
13181318interactive prompt::
@@ -1540,7 +1540,7 @@ FileType objects
15401540
15411541 The :class: `FileType ` factory creates objects that can be passed to the type
15421542 argument of :meth: `ArgumentParser.add_argument `. Arguments that have
1543- :class: `FileType ` objects as their type will open command-line args as files
1543+ :class: `FileType ` objects as their type will open command-line arguments as files
15441544 with the requested modes and buffer sizes:
15451545
15461546 >>> parser = argparse.ArgumentParser()
@@ -1654,7 +1654,7 @@ Parser defaults
16541654.. method :: ArgumentParser.set_defaults(**kwargs)
16551655
16561656 Most of the time, the attributes of the object returned by :meth: `parse_args `
1657- will be fully determined by inspecting the command-line args and the argument
1657+ will be fully determined by inspecting the command-line arguments and the argument
16581658 actions. :meth: `set_defaults ` allows some additional
16591659 attributes that are determined without any inspection of the command line to
16601660 be added::
0 commit comments