[issue16977] argparse: mismatch between choices parsing and usage/error message

Eric V. Smith report at bugs.python.org
Thu Jan 17 15:55:06 CET 2013


Eric V. Smith added the comment:

Isn't this really just an inappropriate use of a string instead of a list? If indeed this is in the documentation, it should be changed.

I still don't like:
>>> p.add_argument('a', choices=list('abc'))
but at least it would work.

This call to list() could be done internally, but I think passing in a string is a bad practice and argparse should not contain internal workarounds to cater to this usage.

If you're proposing that argparse should use sequence iteration instead of the "in" operator, I disagree with that solution.

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16977>
_______________________________________


More information about the Python-bugs-list mailing list