@@ -584,8 +584,7 @@ def _metavar_formatter(self, action, default_metavar): |
584 | 584 | if action.metavar is not None: |
585 | 585 | result = action.metavar |
586 | 586 | elif action.choices is not None: |
587 | | - choice_strs = [str(choice) for choice in action.choices] |
588 | | - result = '{%s}' % ','.join(choice_strs) |
| 587 | + result = '{%s}' % ','.join(map(str, action.choices)) |
589 | 588 | else: |
590 | 589 | result = default_metavar |
591 | 590 |
|
@@ -633,8 +632,7 @@ def _expand_help(self, action): |
633 | 632 | if hasattr(params[name], '__name__'): |
634 | 633 | params[name] = params[name].__name__ |
635 | 634 | if params.get('choices') is not None: |
636 | | - choices_str = ', '.join([str(c) for c in params['choices']]) |
637 | | - params['choices'] = choices_str |
| 635 | + params['choices'] = ', '.join(map(str, params['choices'])) |
638 | 636 | return self._get_help_string(action) % params |
639 | 637 |
|
640 | 638 | def _iter_indented_subactions(self, action): |
@@ -743,7 +741,7 @@ def _get_action_name(argument): |
743 | 741 | elif argument.dest not in (None, SUPPRESS): |
744 | 742 | return argument.dest |
745 | 743 | elif argument.choices: |
746 | | - return '{' + ','.join(argument.choices) + '}' |
| 744 | + return '{%s}' % ','.join(map(str, argument.choices)) |
747 | 745 | else: |
748 | 746 | return None |
749 | 747 |
|
@@ -2613,7 +2611,7 @@ def _check_value(self, action, value): |
2613 | 2611 | # converted value must be one of the choices (if specified) |
2614 | 2612 | if action.choices is not None and value not in action.choices: |
2615 | 2613 | args = {'value': value, |
2616 | | - 'choices': ', '.join(map(repr, action.choices))} |
| 2614 | + 'choices': ', '.join(map(str, action.choices))} |
2617 | 2615 | msg = _('invalid choice: %(value)r (choose from %(choices)s)') |
2618 | 2616 | raise ArgumentError(action, msg % args) |
2619 | 2617 |
|
|