all Python 3argparseterm
argparse.HelpFormatter
help formatters
The default help formatter: it builds the usage and help text and wraps lines to the terminal width. All other argparse formatters derive from it.
Syntax
argparse.ArgumentParser(formatter_class=argparse.HelpFormatter)
It reflows paragraphs: newlines and indentation in description and help collapse into spaces, so hand-formatted help text ends up on one line. Only the class name is public API; its methods are an implementation detail, so subclassing it to override methods is fragile. To keep line breaks, choose RawDescriptionHelpFormatter or RawTextHelpFormatter.
Examples
import argparse
parser = argparse.ArgumentParser(prog='app', description='Строка 1\n Строка 2')
print(parser.format_help()) # → usage: app [-h] / Строка 1 Строка 2 — переносы схлопнуты
See also
Open in the full glossarydocs.python.orgReport an inaccuracy