paul j3 added the comment:

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).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9625>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to