Skip to main content

ArgumentParser

Standard library class argparse.ArgumentParser View source
class ArgumentParser
class ArgumentParser
Fields 13
prog str
usage Optional[str]
description Optional[str]
epilog Optional[str]
prefix_chars str
fromfile_prefix_chars Optional[str]
argument_default ArgumentValue
conflict_handler str
allow_abbrev bool
exit_on_error bool
suggest_on_error bool
color bool
formatter_class Callable[([str], HelpFormatter)]
Constructors 1
__init__
__init__(self: Self, prog: Optional[str] = None, usage: Optional[str] = None, description: Optional[str] = None, epilog: Optional[str] = None, parents = None, formatter_class = HelpFormatter, prefix_chars: str = "-", fromfile_prefix_chars: Optional[str] = None, argument_default = None, conflict_handler: str = "error", add_help: bool = True, allow_abbrev: bool = True, exit_on_error: bool = True, *, suggest_on_error: bool = False, color: bool = True)
Defined in argparse
Methods 18
add_argument
add_argument(self: Self, *names, **kwargs)
Defined in argparse
add_argument_group
add_argument_group(self: Self, title: str = "", description: Optional[str] = None)
Defined in argparse
add_mutually_exclusive_group
add_mutually_exclusive_group(self: Self, *, required: bool = False)
Defined in argparse
add_subparsers
add_subparsers(self: Self, *, title: Optional[str] = None, description: Optional[str] = None, prog: Optional[str] = None, parser_class = None, dest: str = SUPPRESS, required: bool = False, help: Optional[str] = None, metavar = None)
Defined in argparse
set_defaults
set_defaults(self: Self, **kwargs)
Defined in argparse
get_default
get_default(self: Self, dest: str) -> ArgumentValue
Defined in argparse
register
register[registry_name: Literal[str]](self: Self, value: str, object)
Defined in argparse
parse_args
parse_args(self: Self, args = None, namespace = None) -> Namespace
Defined in argparse
parse_known_args
parse_known_args(self: Self, args = None, namespace = None)
Defined in argparse
parse_intermixed_args
parse_intermixed_args(self: Self, args = None, namespace = None) -> Namespace
Defined in argparse
parse_known_intermixed_args
parse_known_intermixed_args(self: Self, args = None, namespace = None)
Defined in argparse
convert_arg_line_to_args
convert_arg_line_to_args(self: Self, arg_line: str) -> List[str]
Defined in argparse
exit
exit(self: Self, status: int = 0, message: Optional[str] = None)
Defined in argparse
error
error(self: Self, message: str)
Defined in argparse
format_usage
format_usage(self: Self) -> str
Defined in argparse
format_help
format_help(self: Self) -> str
Defined in argparse
print_usage
print_usage(self: Self, file = None)
Defined in argparse
print_help
print_help(self: Self, file = None)
Defined in argparse