File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -1058,16 +1058,21 @@ if the argument was not one of the acceptable values::
1058
1058
game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',
1059
1059
'paper', 'scissors')
1060
1060
1061
- Note that inclusion in the *choices * sequence is checked after any type _
1062
- conversions have been performed, so the type of the objects in the *choices *
1063
- sequence should match the type _ specified.
1064
-
1065
1061
Any sequence can be passed as the *choices * value, so :class: `list ` objects,
1066
1062
:class: `tuple ` objects, and custom sequences are all supported.
1067
1063
1068
1064
Use of :class: `enum.Enum ` is not recommended because it is difficult to
1069
1065
control its appearance in usage, help, and error messages.
1070
1066
1067
+ Note that *choices * are checked after any type _
1068
+ conversions have been performed, so objects in *choices *
1069
+ should match the type _ specified. This can make *choices *
1070
+ appear unfamiliar in usage, help, or error messages.
1071
+
1072
+ To keep *choices * user-friendly, consider a custom type wrapper that
1073
+ converts and formats values, or omit type _ and handle conversion in
1074
+ your application code.
1075
+
1071
1076
Formatted choices override the default *metavar * which is normally derived
1072
1077
from *dest *. This is usually what you want because the user never sees the
1073
1078
*dest * parameter. If this display isn't desirable (perhaps because there are
You can’t perform that action at this time.
0 commit comments