@@ -548,8 +548,7 @@ def _metavar_formatter(self, action, default_metavar):
548548 if action .metavar is not None :
549549 result = action .metavar
550550 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 ))
553552 else :
554553 result = default_metavar
555554
@@ -597,8 +596,7 @@ def _expand_help(self, action):
597596 if hasattr (params [name ], '__name__' ):
598597 params [name ] = params [name ].__name__
599598 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' ]))
602600 return self ._get_help_string (action ) % params
603601
604602 def _iter_indented_subactions (self , action ):
@@ -707,7 +705,7 @@ def _get_action_name(argument):
707705 elif argument .dest not in (None , SUPPRESS ):
708706 return argument .dest
709707 elif argument .choices :
710- return '{' + ',' .join (argument .choices ) + '}'
708+ return '{%s}' % ',' .join (map ( str , argument .choices ))
711709 else :
712710 return None
713711
@@ -2556,8 +2554,8 @@ def _check_value(self, action, value):
25562554 # converted value must be one of the choices (if specified)
25572555 if action .choices is not None and value not in action .choices :
25582556 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)' )
25612559 raise ArgumentError (action , msg % args )
25622560
25632561 # =======================
0 commit comments