[New-bugs-announce] [issue10984] argparse add_mutually_exclusive_group should accept existing arguments to register conflicts

Chris Lasher 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.
http://stackoverflow.com/questions/4770576/does-argparse-python-support-mutually-exclusive-groups-of-arguments

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
http://pypi.python.org/pypi/ConflictsOptionParser/

----------
components: Library (Lib)
messages: 126862
nosy: gotgenes
priority: normal
severity: normal
status: open
title: argparse add_mutually_exclusive_group should accept existing arguments to register conflicts
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10984>
_______________________________________


More information about the New-bugs-announce mailing list