argparse.FileType

class argparse.FileType(mode='r', bufsize=-1, encoding=None, errors=None) The FileType factory creates objects that can be passed to the type argument of ArgumentParser.add_argument(). Arguments that have FileType objects as their type will open command-line arguments as files with the requested modes, buffer sizes, encodings and error handling (see the open() function for more details): >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--raw', type=argparse.F

argparse.ArgumentParser.print_help()

ArgumentParser.print_help(file=None) Print a help message, including the program usage and information about the arguments registered with the ArgumentParser. If file is None, sys.stdout is assumed.

argparse.ArgumentParser.parse_args()

ArgumentParser.parse_args(args=None, namespace=None) Convert argument strings to objects and assign them as attributes of the namespace. Return the populated namespace. Previous calls to add_argument() determine exactly what objects are created and how they are assigned. See the documentation for add_argument() for details. By default, the argument strings are taken from sys.argv, and a new empty Namespace object is created for the attributes.

argparse.ArgumentParser.format_usage()

ArgumentParser.format_usage() Return a string containing a brief description of how the ArgumentParser should be invoked on the command line.

argparse.ArgumentParser.format_help()

ArgumentParser.format_help() Return a string containing a help message, including the program usage and information about the arguments registered with the ArgumentParser.

argparse.ArgumentParser.parse_known_args()

ArgumentParser.parse_known_args(args=None, namespace=None)

argparse.ArgumentParser.get_default()

ArgumentParser.get_default(dest) Get the default value for a namespace attribute, as set by either add_argument() or by set_defaults(): >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', default='badger') >>> parser.get_default('foo') 'badger'

argparse.ArgumentParser.convert_arg_line_to_args()

ArgumentParser.convert_arg_line_to_args(arg_line) Arguments that are read from a file (see the fromfile_prefix_chars keyword argument to the ArgumentParser constructor) are read one argument per line. convert_arg_line_to_args() can be overridden for fancier reading. This method takes a single argument arg_line which is a string read from the argument file. It returns a list of arguments parsed from this string. The method is called once per line read from the argument file, in order. A usefu

argparse.ArgumentParser.add_argument_group()

ArgumentParser.add_argument_group(title=None, description=None) By default, ArgumentParser groups command-line arguments into “positional arguments” and “optional arguments” when displaying help messages. When there is a better conceptual grouping of arguments than this default one, appropriate groups can be created using the add_argument_group() method: >>> parser = argparse.ArgumentParser(prog='PROG', add_help=False) >>> group = parser.add_argument_group('group') >>

argparse.ArgumentParser.add_subparsers()

ArgumentParser.add_subparsers([title][, description][, prog][, parser_class][, action][, option_string][, dest][, help][, metavar]) Many programs split up their functionality into a number of sub-commands, for example, the svn program can invoke sub-commands like svn checkout, svn update, and svn commit. Splitting up functionality this way can be a particularly good idea when a program performs several different functions which require different kinds of command-line arguments. ArgumentParse