@@ -588,8 +588,7 @@ def _metavar_formatter(self, action, default_metavar):
588588 if action .metavar is not None :
589589 result = action .metavar
590590 elif action .choices is not None :
591- choice_strs = [str (choice ) for choice in action .choices ]
592- result = '{%s}' % ',' .join (choice_strs )
591+ result = '{%s}' % ',' .join (map (str , action .choices ))
593592 else :
594593 result = default_metavar
595594
@@ -637,8 +636,7 @@ def _expand_help(self, action):
637636 if hasattr (params [name ], '__name__' ):
638637 params [name ] = params [name ].__name__
639638 if params .get ('choices' ) is not None :
640- choices_str = ', ' .join ([str (c ) for c in params ['choices' ]])
641- params ['choices' ] = choices_str
639+ params ['choices' ] = ', ' .join (map (str , params ['choices' ]))
642640 return self ._get_help_string (action ) % params
643641
644642 def _iter_indented_subactions (self , action ):
@@ -763,7 +761,7 @@ def _get_action_name(argument):
763761 elif argument .dest not in (None , SUPPRESS ):
764762 return argument .dest
765763 elif argument .choices :
766- return '{' + ',' .join (argument .choices ) + '}'
764+ return '{%s}' % ',' .join (map ( str , argument .choices ))
767765 else :
768766 return None
769767
@@ -2600,8 +2598,8 @@ def _check_value(self, action, value):
26002598 if isinstance (choices , str ):
26012599 choices = iter (choices )
26022600 if value not in choices :
2603- args = {'value' : value ,
2604- 'choices' : ', ' .join (map (repr , action .choices ))}
2601+ args = {'value' : str ( value ) ,
2602+ 'choices' : ', ' .join (map (str , action .choices ))}
26052603 msg = _ ('invalid choice: %(value)r (choose from %(choices)s)' )
26062604 raise ArgumentError (action , msg % args )
26072605
0 commit comments