Export to GitHub

argparse - issue #90

.add_mutually_exclusive_group() only works when child of parser but not when a child of argument group


Posted on Mar 10, 2014 by Helpful Lion

What steps will reproduce the problem?

parser = argparse.ArgumentParser() group = parser.add_argument_group("Mutually exclusive group") megroup = group.add_mutually_exclusive_group()

 megroup.add_argument() won't create mutually exlusive option.

megroup2 = parser.add_mutually_exclusive_group()

Works as expected

What is the expected output? What do you see instead?

You should be able to create a mutually exclusive group as a child of an argument group.

What version of the product are you using? On what operating system? argpase 1.2.1

Please provide any additional information below.

Tested on Python 2.7 where this works correctly. The exact same code on Python 2.6 with argparse 1.2.1 won't enforce mutual exclusion.

Attachments

Status: New

Labels:
Type-Defect Priority-Medium