@@ -548,8 +548,7 @@ def _metavar_formatter(self, action, default_metavar):
548
548
if action .metavar is not None :
549
549
result = action .metavar
550
550
elif action .choices is not None :
551
- choice_strs = [str (choice ) for choice in action .choices ]
552
- result = '{%s}' % ',' .join (choice_strs )
551
+ result = '{%s}' % ',' .join (map (str , action .choices ))
553
552
else :
554
553
result = default_metavar
555
554
@@ -597,8 +596,7 @@ def _expand_help(self, action):
597
596
if hasattr (params [name ], '__name__' ):
598
597
params [name ] = params [name ].__name__
599
598
if params .get ('choices' ) is not None :
600
- choices_str = ', ' .join ([str (c ) for c in params ['choices' ]])
601
- params ['choices' ] = choices_str
599
+ params ['choices' ] = ', ' .join (map (str , params ['choices' ]))
602
600
return self ._get_help_string (action ) % params
603
601
604
602
def _iter_indented_subactions (self , action ):
@@ -707,7 +705,7 @@ def _get_action_name(argument):
707
705
elif argument .dest not in (None , SUPPRESS ):
708
706
return argument .dest
709
707
elif argument .choices :
710
- return '{' + ',' .join (argument .choices ) + '}'
708
+ return '{%s}' % ',' .join (map ( str , argument .choices ))
711
709
else :
712
710
return None
713
711
@@ -2556,8 +2554,8 @@ def _check_value(self, action, value):
2556
2554
# converted value must be one of the choices (if specified)
2557
2555
if action .choices is not None and value not in action .choices :
2558
2556
args = {'value' : value ,
2559
- 'choices' : ', ' .join (map (repr , action .choices ))}
2560
- msg = _ ('invalid choice: %(value)r (choose from %(choices)s)' )
2557
+ 'choices' : ', ' .join (map (str , action .choices ))}
2558
+ msg = _ ('invalid choice: %(value)s (choose from %(choices)s)' )
2561
2559
raise ArgumentError (action , msg % args )
2562
2560
2563
2561
# =======================
0 commit comments