[issue18943] argparse: default args in mutually exclusive groups

Vincas Dargis report at bugs.python.org
Wed Dec 6 12:58:07 EST 2017


Vincas Dargis <vindrg at gmail.com> added the comment:

On 2017-12-06 19:43, paul j3 wrote:
> With one flag but not its argument, I get the error that you display.  That has nothing to do with the grouping.
> 
> 0932:~/mypy/argdev$ python3 issue18943.py --ptz-get-status
> usage: issue18943.py [-h]
>                       (--device-get-capabilities | --ptz-absolute-move x y z | --ptz-get-status MEDIA_PROFILE)
> issue18943.py: error: argument --ptz-get-status: expected one argument

In my example I pasted, I had hardcoded arguments:

```
pprint.pprint(parser.parse_args(['--ptz-get-status']))
``

I expected `python myscript.py --ptz-get-status` to work, because default value is set.

I do not compute that "With one flag but not its argument", sorry. It has default argument set, shoudn't that work?

Thanks!

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue18943>
_______________________________________


More information about the Python-bugs-list mailing list