@@ -702,7 +702,7 @@ The add_argument() method
702
702
703
703
* type _ - The type to which the command-line argument should be converted.
704
704
705
- * choices _ - A container of the allowable values for the argument.
705
+ * choices _ - A sequence of the allowable values for the argument.
706
706
707
707
* required _ - Whether or not the command-line option may be omitted
708
708
(optionals only).
@@ -1124,7 +1124,7 @@ choices
1124
1124
^^^^^^^
1125
1125
1126
1126
Some command-line arguments should be selected from a restricted set of values.
1127
- These can be handled by passing a container object as the *choices * keyword
1127
+ These can be handled by passing a sequence object as the *choices * keyword
1128
1128
argument to :meth: `~ArgumentParser.add_argument `. When the command line is
1129
1129
parsed, argument values will be checked, and an error message will be displayed
1130
1130
if the argument was not one of the acceptable values::
@@ -1138,9 +1138,9 @@ if the argument was not one of the acceptable values::
1138
1138
game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',
1139
1139
'paper', 'scissors')
1140
1140
1141
- Note that inclusion in the *choices * container is checked after any type _
1141
+ Note that inclusion in the *choices * sequence is checked after any type _
1142
1142
conversions have been performed, so the type of the objects in the *choices *
1143
- container should match the type _ specified::
1143
+ sequence should match the type _ specified::
1144
1144
1145
1145
>>> parser = argparse.ArgumentParser(prog='doors.py')
1146
1146
>>> parser.add_argument('door', type=int, choices=range(1, 4))
@@ -1150,8 +1150,8 @@ container should match the type_ specified::
1150
1150
usage: doors.py [-h] {1,2,3}
1151
1151
doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)
1152
1152
1153
- Any container can be passed as the *choices * value, so :class: `list ` objects,
1154
- :class: `set ` objects, and custom containers are all supported.
1153
+ Any sequence can be passed as the *choices * value, so :class: `list ` objects,
1154
+ :class: `tuple ` objects, and custom sequences are all supported.
1155
1155
1156
1156
Use of :class: `enum.Enum ` is not recommended because it is difficult to
1157
1157
control its appearance in usage, help, and error messages.
0 commit comments