File tree Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Original file line number Diff line number Diff line change @@ -1133,20 +1133,9 @@ container should match the type_ specified::
1133
1133
1134
1134
Any container can be passed as the *choices * value, so :class: `list ` objects,
1135
1135
:class: `set ` objects, and custom containers are all supported.
1136
- This includes :class: `enum.Enum `, which could be used to restrain
1137
- argument's choices; if we reuse previous rock/paper/scissors game example,
1138
- this could be as follows::
1139
-
1140
- >>> from enum import Enum
1141
- >>> class GameMove(Enum):
1142
- ... ROCK = 'rock'
1143
- ... PAPER = 'paper'
1144
- ... SCISSORS = 'scissors'
1145
- ...
1146
- >>> parser = argparse.ArgumentParser(prog='game.py')
1147
- >>> parser.add_argument('move', type=GameMove, choices=GameMove)
1148
- >>> parser.parse_args(['rock'])
1149
- Namespace(move=<GameMove.ROCK: 'rock'>)
1136
+
1137
+ Use of :class: `enum.Enum ` is not recommended because it is difficult to
1138
+ control its appearance in usage, help, and error messages.
1150
1139
1151
1140
1152
1141
required
You can’t perform that action at this time.
0 commit comments