@@ -547,8 +547,7 @@ def _metavar_formatter(self, action, default_metavar):
547547 if action .metavar is not None :
548548 result = action .metavar
549549 elif action .choices is not None :
550- choice_strs = [str (choice ) for choice in action .choices ]
551- result = '{%s}' % ',' .join (choice_strs )
550+ result = '{%s}' % ',' .join (map (str , action .choices ))
552551 else :
553552 result = default_metavar
554553
@@ -596,8 +595,7 @@ def _expand_help(self, action):
596595 if hasattr (params [name ], '__name__' ):
597596 params [name ] = params [name ].__name__
598597 if params .get ('choices' ) is not None :
599- choices_str = ', ' .join ([str (c ) for c in params ['choices' ]])
600- params ['choices' ] = choices_str
598+ params ['choices' ] = ', ' .join (map (str , params ['choices' ]))
601599 return self ._get_help_string (action ) % params
602600
603601 def _iter_indented_subactions (self , action ):
@@ -714,7 +712,7 @@ def _get_action_name(argument):
714712 elif argument .dest not in (None , SUPPRESS ):
715713 return argument .dest
716714 elif argument .choices :
717- return '{' + ',' .join (argument .choices ) + '}'
715+ return '{%s}' % ',' .join (map ( str , argument .choices ))
718716 else :
719717 return None
720718
@@ -2595,8 +2593,8 @@ def _check_value(self, action, value):
25952593 if isinstance (choices , str ):
25962594 choices = iter (choices )
25972595 if value not in choices :
2598- args = {'value' : value ,
2599- 'choices' : ', ' .join (map (repr , action .choices ))}
2596+ args = {'value' : str ( value ) ,
2597+ 'choices' : ', ' .join (map (str , action .choices ))}
26002598 msg = _ ('invalid choice: %(value)r (choose from %(choices)s)' )
26012599 raise ArgumentError (action , msg % args )
26022600
0 commit comments