homepage

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 chris.jerdonek
Recipients chris.jerdonek, terry.reedy
Date 2012年11月14日.04:32:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1352867539.71.0.970228461518.issue16468@psf.upfronthosting.co.za>
In-reply-to
Content
This issue is to ensure that argparse.ArgumentParser() accepts objects that support the "in" operator for the "choices" argument to ArgumentParser.add_argument().
As observed by Terry in the comments to issue 16418:
http://bugs.python.org/issue16418#msg175520
the argparse module does not in general support "choices" values that support the "in" operator, even though the argparse documentation says it does:
"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/2/library/argparse.html#choices )
For example, passing a user-defined type that implements only self.__contains__() yields the following error message when calling ArgumentParser.parse_args():
File ".../Lib/argparse.py", line 1293, in add_argument
 raise ValueError("length of metavar tuple does not match nargs")
(The error message also gives the wrong reason for failure. The swallowed exception is "TypeError: '<class>' object is not iterable.")
History
Date User Action Args
2012年11月14日 04:32:19chris.jerdoneksetrecipients: + chris.jerdonek, terry.reedy
2012年11月14日 04:32:19chris.jerdoneksetmessageid: <1352867539.71.0.970228461518.issue16468@psf.upfronthosting.co.za>
2012年11月14日 04:32:19chris.jerdoneklinkissue16468 messages
2012年11月14日 04:32:17chris.jerdonekcreate

AltStyle によって変換されたページ (->オリジナル) /