bpo-29626: spacing issue when using help in argparse by csabella · Pull Request #1835 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @serhiy-storchaka . I've been looking at this trying to figure out what you meant by using a single extend() call.
The original code is:
else:
default = self._get_default_metavar_for_optional(action)
args_string = self._format_args(action, default)
for option_string in action.option_strings:
parts.append('%s %s' % (option_string, args_string))
So, are you saying that this change would be:
else:
default = self._get_default_metavar_for_optional(action)
args_string = self._format_args(action, default)
if not args_string:
parts.extend(action.option_strings)
else:
for option_string in action.option_strings:
parts.append('%s %s' % (option_string, args_string))
or is there a way to incorporate the existing value string append parts.append('%s %s' % (option_string, args_string)) into the extend() as well?
Sorry if this is a basic question.