New submission from Clint Olsen <clint.ol...@gmail.com>:

When I run the following program, I expect args.run to be 'foo' if no argument 
is specified on the command-line.

parser = argparse.ArgumentParser()

parser.add_argument('foo', default='bar')

args = parser.parse_args()

$ ./test
usage: test [-h] foo
test: error: the following arguments are required: foo

However if I specify nargs='*' this error goes away.

Maybe I'm missing something obvious, but this seems non-intuitive to me.

----------
components: Library (Lib)
messages: 386770
nosy: Clint Olsen
priority: normal
severity: normal
status: open
title: Argparse complains argument required when default is provided
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43192>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to