[New-bugs-announce] [issue16697] argparse kwarg 'choices' documentation
wim glenn
report at bugs.python.org
Sun Dec 16 14:53:55 CET 2012
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-infinite-set
----------
assignee: docs at python
components: Documentation
messages: 177599
nosy: docs at python, wim.glenn
priority: normal
severity: normal
status: open
title: argparse kwarg 'choices' documentation
type: enhancement
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16697>
_______________________________________
More information about the New-bugs-announce
mailing list