On this page
argparse.RawTextHelpFormatter
Prev: argparse.RawDescriptionHelpFormatter | Up: argparse
Rel: argparse.Action, argparse.ArgumentDefaultsHelpFormatter, argparse.ArgumentError, argparse.ArgumentParser
Ref: docs.python.org — argparse.RawTextHelpFormatter
Tags: #public #python3 #stdlib #argparse
Import
import argparse
from argparse import RawTextHelpFormatter
Signature & Overview
argparse.RawTextHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None, color=True)
Help message formatter which retains formatting of all help text.
Methods & Attributes
RawTextHelpFormatter.add_argument(self, action)—RawTextHelpFormatter.add_argumentmethod/property.RawTextHelpFormatter.add_arguments(self, actions)—RawTextHelpFormatter.add_argumentsmethod/property.RawTextHelpFormatter.add_text(self, text)—RawTextHelpFormatter.add_textmethod/property.RawTextHelpFormatter.add_usage(self, usage, actions, groups, prefix=None)—RawTextHelpFormatter.add_usagemethod/property.RawTextHelpFormatter.end_section(self)—RawTextHelpFormatter.end_sectionmethod/property.RawTextHelpFormatter.format_help(self)—RawTextHelpFormatter.format_helpmethod/property.RawTextHelpFormatter.start_section(self, heading)—RawTextHelpFormatter.start_sectionmethod/property.
Usage
import argparse
p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
p.add_argument("--mode", help="fast: skip checks\nsafe: full validation")
assert "fast: skip checks\n" in p.format_help()
Gotchas
- No automatic line wrapping: You are responsible for keeping
description,epilog, andhelp=lines within terminal width.
REPL Inspect
from argparse import RawTextHelpFormatter
help(RawTextHelpFormatter)
Linked from
Related notes
- tuts/python3/stdlib_module/argparse/RawDescriptionHelpFormatter 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
- tuts/python3/stdlib_module/argparse/HelpFormatter shared tags: #argparse, #stdlib