This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wim.glenn
Recipients docs@python, wim.glenn
Date 2012-12-16.13:53:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1355666035.13.0.877787561314.issue16697@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2012-12-16 13:53:55wim.glennsetrecipients: + wim.glenn, docs@python
2012-12-16 13:53:55wim.glennsetmessageid: <1355666035.13.0.877787561314.issue16697@psf.upfronthosting.co.za>
2012-12-16 13:53:55wim.glennlinkissue16697 messages
2012-12-16 13:53:54wim.glenncreate