Message217677
There's a complicating issue - should these default values be passed through the type function?
In most cases in `_get_values`, the string first goes through `_get_value`, and then to `_check_value`.
For example the 'else:' case:
value = [self._get_value(action, v) for v in arg_strings]
for v in value:
self._check_value(action, v)
The '*' positional case could coded the same way, allowing:
parser.add_argument('foo',
nargs='*',
type=int,
choices=range(5),
default=['0',1,'2'])
and objecting to
default=[6,'7','a'] # out of range string or int or invalid value
This does impose a further constraint on the 'type' function, that it accepts a converted value. e.g. int(1) is as valid as int('1').
But we need to be careful that this case is handled in a way that is consistent with other defaults (including the recent change that delayed evaluating defaults till the end). |
|
Date |
User |
Action |
Args |
2014-05-01 04:46:43 | paul.j3 | set | recipients:
+ paul.j3, bethard, eric.smith, eric.araujo, ced, thesociable, regis |
2014-05-01 04:46:43 | paul.j3 | set | messageid: <1398919603.69.0.465127876259.issue9625@psf.upfronthosting.co.za> |
2014-05-01 04:46:43 | paul.j3 | link | issue9625 messages |
2014-05-01 04:46:42 | paul.j3 | create | |
|