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 paul.j3
Recipients bethard, ced, eric.araujo, eric.smith, paul.j3, regis, thesociable
Date 2014-05-01.04:46:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1398919603.69.0.465127876259.issue9625@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2014-05-01 04:46:43paul.j3setrecipients: + paul.j3, bethard, eric.smith, eric.araujo, ced, thesociable, regis
2014-05-01 04:46:43paul.j3setmessageid: <1398919603.69.0.465127876259.issue9625@psf.upfronthosting.co.za>
2014-05-01 04:46:43paul.j3linkissue9625 messages
2014-05-01 04:46:42paul.j3create