[issue16697] argparse kwarg 'choices' documentation
New submission from wim glenn: Any object that supports the in operator can be passed as the choices value, so dict objects, set objects, custom containers, etc. are all supported. (from http://docs.python.org/dev/library/argparse.html#choices ) Actual behaviour is contradicted by the docs - it seems the container must additionally be iterable. When using a custom container, argparse b0rks on trying to iterate through choices. Using a metavar prevents this, but it still breaks on cases where the element is not in the container. More details here: http://stackoverflow.com/questions/13833566/python-argparse-choices-from-an-... ---------- assignee: docs@python components: Documentation messages: 177599 nosy: docs@python, wim.glenn priority: normal severity: normal status: open title: argparse kwarg 'choices' documentation type: enhancement versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16697> _______________________________________
R. David Murray added the comment: This is a duplicate of issue issue 16468, which may get closed with either a bug fix or a doc fix, depending on the outcome of the overall discussion. ---------- nosy: +r.david.murray resolution: -> duplicate stage: -> committed/rejected status: open -> closed superseder: -> argparse only supports iterable choices type: enhancement -> behavior _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16697> _______________________________________
Changes by wim glenn <wim.glenn@gmail.com>: ---------- nosy: -wim.glenn _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16697> _______________________________________
Brendan Barnwell <brenbarn@brenbarn.net> added the comment: This issue has sat idle for six years. Meanwhile, the docs are still incorrect, giving every user wrong information about how the module works. Can we consider just changing the documentation instead of worrying about what the behavior should be or what the rationale is? ---------- nosy: +BrenBarn versions: +Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue16697> _______________________________________
participants (3)
-
Brendan Barnwell
-
R. David Murray
-
wim glenn