diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2020-11-30 17:55:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 17:55:13 (GMT) |
commit | 7f82f22eba1312617e1aa19cb916da1aae1609a4 (patch) | |
tree | 66272b42639abd26b64c3c12d5c80e55a0f7236e /Doc/library/argparse.rst | |
parent | e41bfd15dd148627b4f39c2a5837bddd8894d345 (diff) | |
download | cpython-7f82f22eba1312617e1aa19cb916da1aae1609a4.zip cpython-7f82f22eba1312617e1aa19cb916da1aae1609a4.tar.gz cpython-7f82f22eba1312617e1aa19cb916da1aae1609a4.tar.bz2 |
bpo-42501: Revise the usage note for Enums with the choices (GH-23563)
Diffstat (limited to 'Doc/library/argparse.rst')
-rw-r--r-- | Doc/library/argparse.rst | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 7a7a4cf..a32b999 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1133,20 +1133,9 @@ container should match the type_ specified:: Any container can be passed as the *choices* value, so :class:`list` objects, :class:`set` objects, and custom containers are all supported. -This includes :class:`enum.Enum`, which could be used to restrain -argument's choices; if we reuse previous rock/paper/scissors game example, -this could be as follows:: - - >>> from enum import Enum - >>> class GameMove(Enum): - ... ROCK = 'rock' - ... PAPER = 'paper' - ... SCISSORS = 'scissors' - ... - >>> parser = argparse.ArgumentParser(prog='game.py') - >>> parser.add_argument('move', type=GameMove, choices=GameMove) - >>> parser.parse_args(['rock']) - Namespace(move=<GameMove.ROCK: 'rock'>) + +Use of :class:`enum.Enum` is not recommended because it is difficult to +control its appearance in usage, help, and error messages. required |