Next / Previous / Contents / TCC Help System / NM Tech homepage

28.10.3. The ArgumentParser() constructor

Here is the calling sequence to create an ArgumentParser instance P:

import argparse

P = argparse.ArgumentParser(**kw)

Valid keyword arguments include:


A string describing the overall purpose of your script. This string will be displayed in the generated help message.


By default, the returned parser will implement options -h and --help to display the help message showing the valid option syntax. Use add_help=False if you don't want this behavior.


By default, when the name of your script is displayed, it will be the name from sys.argv[0]. If you would like to display a different program name, pass that name as the value of this keyword argument.

Here's an example.

parser = argparse.ArgumentParser(prog="nile-source",
              description="Find the source of the Nile")