Author michelsen
Recipients loewis, michelsen
Date 2010-12-11.16:32:21
SpamBayes Score 3.97875e-11
Marked as misclassified No
Message-id <1292085144.33.0.787280353146.issue10680@psf.upfronthosting.co.za>
In-reply-to
Content
Okay, I'll try:

Save the following code as argparse_test.py:

[CODE]
#! /usr/bin/env python2

import argparse

def args_config(about):
    parser = argparse.ArgumentParser(description=about)
    dummy_group = parser.add_argument_group(title='mutually exclusive')
    test_group = dummy_group.add_mutually_exclusive_group()
    test_group.add_argument('-a', action='store_true', default=False, \
        help='This is the r option')
    test_group.add_argument('-b', action='store_true', default=False, \
        help='This is the b option')
    test_group.add_argument('-c', action='store_true', default=False, \
        help='And this is the c option')
    args_ns = parser.parse_args()
    return args_ns

about = 'This is a test case'
args_ns = args_config(about)
print args_ns
[/CODE]

The use the -h argument to see help output:

[OUTPUT]
[~] python/argparse_test.py -h
usage: argparse_test.py [-h] [-a] [-b] [-c]

This is a test case

optional arguments:
  -h, --help  show this help message and exit

mutually exclusive:
  -a          This is the r option
  -b          This is the b option
  -c          And this is the c option
[/OUTPUT]

The run it with all the options together to test exclusivity:

[OUTPUT]
[~] python/argparse_test.py -abc
Namespace(a=True, b=True, c=True)
[/OUTPUT]

What happens: As you can see, there are no objections to using all three options at the same time. Neither does the help output indicate that there should be.

What should happen:
If I have understood the instructions in the Issue report on Google correctly, the assumption is that this workaround (i.e. using a dummy group) should produce the desired result (i.e. that running the command argparse_test.py -abc" should appear as and be prbohibited)
History
Date User Action Args
2010-12-11 16:32:24michelsensetrecipients: + michelsen, loewis
2010-12-11 16:32:24michelsensetmessageid: <1292085144.33.0.787280353146.issue10680@psf.upfronthosting.co.za>
2010-12-11 16:32:21michelsenlinkissue10680 messages
2010-12-11 16:32:21michelsencreate