Author rrt
Recipients rrt
Date 2020-09-24.20:23:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1600979030.91.0.326865229332.issue41854@roundup.psfhosted.org>
In-reply-to
Content
The following code:

group = parser.add_mutually_exclusive_group()
group.add_argument('--install-only', action='store_true',
                    help='just install the program, do not run it')
group.add_argument('args', metavar='ARGUMENT', nargs='*', default=None,
                    help='arguments to PROGRAM')

gives the following error:

    group.add_argument('args', metavar='ARGUMENT', nargs='*',
  File "/usr/lib/python3.8/argparse.py", line 1398, in add_argument
    return self._add_action(action)
  File "/usr/lib/python3.8/argparse.py", line 1621, in _add_action
    raise ValueError(msg)
ValueError: mutually exclusive arguments must be optional

But the 'args' argument *is* optional, as there can be 0 of them.
History
Date User Action Args
2020-09-24 20:23:50rrtsetrecipients: + rrt
2020-09-24 20:23:50rrtsetmessageid: <1600979030.91.0.326865229332.issue41854@roundup.psfhosted.org>
2020-09-24 20:23:50rrtlinkissue41854 messages
2020-09-24 20:23:50rrtcreate