Overriding default argparse -h behaviour

If you give the ArgumentParser a conflict_handler="resolve" argument, adding your own -h will override the existing one, while keeping --help functional.

#!/usr/bin/env python3
import argparse
parse = argparse.ArgumentParser(conflict_handler="resolve")
parse.add_argument("-h", "--hello")
print(parse.parse_args())

Look in the argparse documentation for the ArgumentParser arguments. There's one called add_help, which defaults to True.

parser = argparse.ArgumentParser('Cool', add_help=False)
parser.add_argument('-h', '--hi', action='store_true', dest='hi')

This works as expected.


There is a kwarg to suppress that stuff (docs).
Create your parser like this:

parser = argparse.ArgumentParser(prog='PROG', add_help=False)