We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
When using nargs='*' with other required arguments, argparse incorrectly says the optional argument is required.
nargs='*'
usage: example [-h] foo [bar ...] example: error: the following arguments are required: foo, bar
import argparse parser = argparse.ArgumentParser(prog='example') parser.add_argument('foo') parser.add_argument('bar', nargs='*') args = parser.parse_args()
Python 3.9.16
When using
nargs='*'with other required arguments, argparse incorrectly says the optional argument is required.Output (with no arguments)
Code
Python 3.9.16
Linked PRs