Skip to content

Commit ecd4c5f

Browse files
Update Doc/library/argparse.rst
Co-authored-by: Savannah Bailey <savannahostrowski@gmail.com>
1 parent 615e96f commit ecd4c5f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Doc/library/argparse.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,17 +1130,14 @@ Any sequence can be passed as the *choices* value, so :class:`list` objects,
11301130
Use of :class:`enum.Enum` is not recommended because it is difficult to
11311131
control its appearance in usage, help, and error messages.
11321132

1133-
Note that inclusion in the *choices* sequence is checked after any type_
1134-
conversions have been performed, so the type of the objects in the *choices*
1135-
sequence should match the type_ specified. This may interfere with
1136-
the display of the choices in usage, help and error messages, because the
1137-
*choices* may not be familiar to the end-user.
1138-
1139-
If you have to use both *type* and *choices* you can use a wrapper class
1140-
that formats the value after type conversion back to the vocabulary of the
1141-
end-user. However, it is usually easier to not specify *type* and perform
1142-
type conversion in application code.
1143-
1133+
Note that *choices* are checked after any type_
1134+
conversions have been performed, so objects in *choices*
1135+
should match the type_ specified. This can make *choices*
1136+
appear unfamiliar in usage, help, or error messages.
1137+
1138+
To keep *choices* user-friendly, consider a custom type wrapper that
1139+
converts and formats values, or omit type_ and handle conversion in
1140+
your application code.
11441141
Formatted choices override the default *metavar* which is normally derived
11451142
from *dest*. This is usually what you want because the user never sees the
11461143
*dest* parameter. If this display isn't desirable (perhaps because there are

0 commit comments

Comments
 (0)