Required vs Optional Arguments

Arguments that start with - or -- are optional arguments, while those that don’t are positional and therefore required (much like positional arguments in Python functions). Even though, arguments starting with - or -- are generally optional, argparse still lets you mark them as required. This is considered bad design in most casee but isn’t prevented.

For example, you can do:

parser = argparse.ArgumentParser()
parser.add_argument('--foo', required=True)

This is how it’s put in the documentation documentation:

Required options are generally considered bad form because users expect options to be optional, and thus they should be avoided when possible.