[New-bugs-announce] [issue10984] argparse add_mutually_exclusive_group should accept existing arguments to register conflicts
report at bugs.python.org
Sun Jan 23 00:02:00 CET 2011
New submission from Chris Lasher <chris.lasher at gmail.com>:
argparse supports registering conflicting arguments, however, it does so in a way that an argument may belong to at most one group of conflicting arguments. The inspiration for this bug is Stack Overflow question #4770576.
The most straightforward use case argparse can not accommodate is the following: the user has three flags, '-a', '-b', and '-c'. The flag '-b' is incompatible with both '-a' and with '-c', however, '-a' and '-c' are compatible with each other.
Current practice is to register a conflict by first defining a conflict group with parser.add_mutually_exclusive_group(), and then create new arguments within that group using group.add_argument(). Because the programmer is not allowed to create the argument prior to creating the group, an argument cannot be registered in two exclusive groups.
I feel it would be much more useful to be given the option to create exclusive groups after the programmer has defined and created the options, as is the design for ConflictsOptionParser
components: Library (Lib)
title: argparse add_mutually_exclusive_group should accept existing arguments to register conflicts
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce