Issue 15336: Argparse required arguments incorrectly displayed as optional arguments (original) (raw)

In this script, '-x' is required argument:

import argparse p = argparse.ArgumentParser() p.add_argument('-x', required=True) p.print_help()

However, the automatically generated help shows it as optional:

usage: ap_demo.py [-h] -x X

optional arguments: -h, --help show this help message and exit -x X