Irit Katriel <iritkatr...@gmail.com> added the comment:
We could make the error message less wrong: >>> p.parse_args(['d']) usage: [-h] {a,b,c} : error: argument a: invalid choice: 'd' (choose a value in 'abc') % git diff diff --git a/Lib/argparse.py b/Lib/argparse.py index b44fa4f0f6..f03cc1f110 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -2499,8 +2499,8 @@ def _check_value(self, action, value): # converted value must be one of the choices (if specified) if action.choices is not None and value not in action.choices: args = {'value': value, - 'choices': ', '.join(map(repr, action.choices))} - msg = _('invalid choice: %(value)r (choose from %(choices)s)') + 'choices': repr(action.choices)} + msg = _('invalid choice: %(value)r (choose a value in %(choices)s)') raise ArgumentError(action, msg % args) # ======================= ---------- nosy: +iritkatriel versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.2, Python 3.3, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue16977> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com