@@ -774,16 +774,16 @@ how the command-line arguments should be handled. The supplied actions are:
774774 >>> parser.parse_args('--foo --bar'.split())
775775 Namespace(foo=True, bar=False, baz=True)
776776
777- * ``'append' `` - This stores a list, and appends each argument value to the
778- list. It is useful to allow an option to be specified multiple times.
779- If the default value is non-empty, the default elements will be present
780- in the parsed value for the option, with any values from the
781- command line appended after those default values. Example usage::
777+ * ``'append' `` - This appends each argument value to a list.
778+ It is useful for allowing an option to be specified multiple times.
779+ If the default value is a non-empty list , the parsed value will start
780+ with the default list's elements and any values from the command line
781+ will be appended after those default values. Example usage::
782782
783783 >>> parser = argparse.ArgumentParser()
784- >>> parser.add_argument('--foo', action='append')
784+ >>> parser.add_argument('--foo', action='append', default=['0'] )
785785 >>> parser.parse_args('--foo 1 --foo 2'.split())
786- Namespace(foo=['1', '2'])
786+ Namespace(foo=['0', ' 1', '2'])
787787
788788* ``'append_const' `` - This stores a list, and appends the value specified by
789789 the const _ keyword argument to the list; note that the const _ keyword
@@ -981,8 +981,8 @@ the various :class:`ArgumentParser` actions. The two most common uses of it are
981981 (like ``-f `` or ``--foo ``) and ``nargs='?' ``. This creates an optional
982982 argument that can be followed by zero or one command-line arguments.
983983 When parsing the command line, if the option string is encountered with no
984- command-line argument following it, the value of ``const `` will be assumed to
985- be `` None `` instead. See the nargs _ description for examples.
984+ command-line argument following it, the value from ``const `` will be used.
985+ See the nargs _ description for examples.
986986
987987.. versionchanged :: 3.11
988988 ``const=None `` by default, including when ``action='append_const' `` or
@@ -1142,16 +1142,21 @@ if the argument was not one of the acceptable values::
11421142 game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',
11431143 'paper', 'scissors')
11441144
1145- Note that inclusion in the *choices * sequence is checked after any type _
1146- conversions have been performed, so the type of the objects in the *choices *
1147- sequence should match the type _ specified.
1148-
11491145Any sequence can be passed as the *choices * value, so :class: `list ` objects,
11501146:class: `tuple ` objects, and custom sequences are all supported.
11511147
11521148Use of :class: `enum.Enum ` is not recommended because it is difficult to
11531149control its appearance in usage, help, and error messages.
11541150
1151+ Note that *choices * are checked after any type _
1152+ conversions have been performed, so objects in *choices *
1153+ should match the type _ specified. This can make *choices *
1154+ appear unfamiliar in usage, help, or error messages.
1155+
1156+ To keep *choices * user-friendly, consider a custom type wrapper that
1157+ converts and formats values, or omit type _ and handle conversion in
1158+ your application code.
1159+
11551160Formatted choices override the default *metavar * which is normally derived
11561161from *dest *. This is usually what you want because the user never sees the
11571162*dest * parameter. If this display isn't desirable (perhaps because there are
0 commit comments