On this page
argparse.RawDescriptionHelpFormatter
Prev: argparse.Namespace | Up: argparse | Next: argparse.RawTextHelpFormatter
Rel: argparse.Action, argparse.ArgumentDefaultsHelpFormatter, argparse.ArgumentError, argparse.ArgumentParser
Ref: docs.python.org — argparse.RawDescriptionHelpFormatter
Tags: #public #python3 #stdlib #argparse
Import
import argparse
from argparse import RawDescriptionHelpFormatter
Signature & Overview
argparse.RawDescriptionHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None, color=True)
Help message formatter which retains any formatting in descriptions.
Methods & Attributes
RawDescriptionHelpFormatter.add_argument(self, action)—RawDescriptionHelpFormatter.add_argumentmethod/property.RawDescriptionHelpFormatter.add_arguments(self, actions)—RawDescriptionHelpFormatter.add_argumentsmethod/property.RawDescriptionHelpFormatter.add_text(self, text)—RawDescriptionHelpFormatter.add_textmethod/property.RawDescriptionHelpFormatter.add_usage(self, usage, actions, groups, prefix=None)—RawDescriptionHelpFormatter.add_usagemethod/property.RawDescriptionHelpFormatter.end_section(self)—RawDescriptionHelpFormatter.end_sectionmethod/property.RawDescriptionHelpFormatter.format_help(self)—RawDescriptionHelpFormatter.format_helpmethod/property.RawDescriptionHelpFormatter.start_section(self, heading)—RawDescriptionHelpFormatter.start_sectionmethod/property.
Usage
import argparse
desc = "Line 1\n Indented line 2"
p = argparse.ArgumentParser(description=desc, formatter_class=argparse.RawDescriptionHelpFormatter)
assert " Indented line 2" in p.format_help()
Gotchas
- Preserves newlines/indentation in
descriptionandepilogonly: Individual argumenthelp=strings are still line-wrapped normally (useRawTextHelpFormatterto keep raw formatting everywhere).
REPL Inspect
from argparse import RawDescriptionHelpFormatter
help(RawDescriptionHelpFormatter)
Linked from
Related notes
- tuts/python3/stdlib_module/argparse/Namespace Linked here; links to this page; shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse/RawTextHelpFormatter Linked here; links to this page; shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/argparse/Action Linked here; shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse/ArgumentDefaultsHelpFormatter Linked here; shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse/ArgumentError Linked here; shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse/ArgumentParser Linked here; shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse/ArgumentTypeError shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse/BooleanOptionalAction shared tags: #argparse, #stdlib
- tuts/python3/stdlib_module/argparse/FileType shared tags: #argparse, #stdlib