Message180068
When passing a string for the choices argument, argparse's usage and error messages differ from its behavior:
>>> p = argparse.ArgumentParser()
>>> p.add_argument('a', choices='abc')
>>> p.parse_args(['d'])
usage: [-h] {a,b,c}
: error: argument a: invalid choice: 'd' (choose from 'a', 'b', 'c')
>>> p.parse_args(['bc'])
Namespace(a='bc')
This is because argparse uses the "in" operator instead of sequence iteration to check whether an argument value is valid. Any resolution should also consider the behavior for string subclasses as well as perhaps bytes-like objects. |
|
Date |
User |
Action |
Args |
2013-01-16 02:30:07 | chris.jerdonek | set | recipients:
+ chris.jerdonek |
2013-01-16 02:30:07 | chris.jerdonek | set | messageid: <1358303407.58.0.0453921356618.issue16977@psf.upfronthosting.co.za> |
2013-01-16 02:30:06 | chris.jerdonek | link | issue16977 messages |
2013-01-16 02:30:06 | chris.jerdonek | create | |
|