[issue43192] Argparse complains argument required when default is provided

2021-05-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Specifying a 'default' with a positional doesn't make much sense. That was my thought as well. Perhaps that is worth a note in the docs but there is likely no real need to change the behavior. -- nosy: +rhettinger _

[issue43192] Argparse complains argument required when default is provided

2021-05-04 Thread paul j3
paul j3 added the comment: To a large degree the Action parameters operate independently. That is, different parts of the code use the parameters for their own purposes. The composite behavior is a result of those individual actors, rather than some sort of overall coordinated plan. First

[issue43192] Argparse complains argument required when default is provided

2021-02-10 Thread Clint Olsen
Clint Olsen added the comment: I think your original suggestion makes sense: '?' My intuition is that nargs helps argparse discern whether it's dealing with single or multiple values. That may not be what was intended. There probably shouldn't be multiple ways of indicating an argument is o

[issue43192] Argparse complains argument required when default is provided

2021-02-10 Thread Eric V. Smith
Eric V. Smith added the comment: Would you infer it to be ‘?’ or ‘*’? I’m not completely opposed, but I haven’t thought it through or looked at the code. -- ___ Python tracker __

[issue43192] Argparse complains argument required when default is provided

2021-02-10 Thread Clint Olsen
Clint Olsen added the comment: Do you think it's unreasonable/unintuitive to infer nargs from the default value? -- ___ Python tracker ___ ___

[issue43192] Argparse complains argument required when default is provided

2021-02-10 Thread Eric V. Smith
Eric V. Smith added the comment: Providing a default value does not imply setting nargs, so you need to specify both. I think it's not clear what nargs would default to, if you wanted to change the behavior if default= is supplied.. In your example you probably want nargs='?', not '*'.

[issue43192] Argparse complains argument required when default is provided

2021-02-10 Thread Clint Olsen
Clint Olsen added the comment: Sorry, I meant to say args.foo should be 'bar'. -- ___ Python tracker ___ ___ Python-bugs-list maili

[issue43192] Argparse complains argument required when default is provided

2021-02-10 Thread Clint Olsen
New submission from Clint Olsen : 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: erro