@@ -765,7 +765,7 @@ The add_argument() method
765
765
766
766
* type _ - The type to which the command-line argument should be converted.
767
767
768
- * choices _ - A container of the allowable values for the argument.
768
+ * choices _ - A sequence of the allowable values for the argument.
769
769
770
770
* required _ - Whether or not the command-line option may be omitted
771
771
(optionals only).
@@ -1209,7 +1209,7 @@ choices
1209
1209
^^^^^^^
1210
1210
1211
1211
Some command-line arguments should be selected from a restricted set of values.
1212
- These can be handled by passing a container object as the *choices * keyword
1212
+ These can be handled by passing a sequence object as the *choices * keyword
1213
1213
argument to :meth: `~ArgumentParser.add_argument `. When the command line is
1214
1214
parsed, argument values will be checked, and an error message will be displayed
1215
1215
if the argument was not one of the acceptable values::
@@ -1223,9 +1223,9 @@ if the argument was not one of the acceptable values::
1223
1223
game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',
1224
1224
'paper', 'scissors')
1225
1225
1226
- Note that inclusion in the *choices * container is checked after any type _
1226
+ Note that inclusion in the *choices * sequence is checked after any type _
1227
1227
conversions have been performed, so the type of the objects in the *choices *
1228
- container should match the type _ specified::
1228
+ sequence should match the type _ specified::
1229
1229
1230
1230
>>> parser = argparse.ArgumentParser(prog='doors.py')
1231
1231
>>> parser.add_argument('door', type=int, choices=range(1, 4))
@@ -1235,8 +1235,8 @@ container should match the type_ specified::
1235
1235
usage: doors.py [-h] {1,2,3}
1236
1236
doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)
1237
1237
1238
- Any container can be passed as the *choices * value, so :class: `list ` objects,
1239
- :class: `set ` objects, and custom containers are all supported.
1238
+ Any sequence can be passed as the *choices * value, so :class: `list ` objects,
1239
+ :class: `tuple ` objects, and custom sequences are all supported.
1240
1240
1241
1241
Use of :class: `enum.Enum ` is not recommended because it is difficult to
1242
1242
control its appearance in usage, help, and error messages.
0 commit comments