paul j3 added the comment:

http://bugs.python.org/issue22047 "argparse improperly prints mutually 
exclusive options when they are in a group"

is similar.

-----

There are two issues:

- the nesting of mutually exclusive groups

- the formatting of the usage in such cases.

Both have come up in one way or other in other bug reports.

Yes, it is possible to add a group to an existing group.  But from a testing 
standpoint the effect is the same as if you put all actions into one super 
group. 

More often people try to nest ArgumentGroups in MutuallyExclusiveGroups 
thinking that would give some sort of 'any' or 'and' logic within the 'xor' 
logic.  I have explored that in 

http://bugs.python.org/issue11588.  

Defining nestable groups is relatively easy.  Writing good usage is much harder.
 
The usage formatter is brittle.  It creates a big string, strips out 'excess' 
characters (the problem here), and then splits and reassembles the string 
(leading to assertion errors if the metavars contain funny characters).

In 

http://bugs.python.org/issue11874  

I submitted a patch that substantially rewrites the usage formatter.  The idea 
was to keep the action strings separate until the last moment.  While I haven't 
tested it with the current problem, I did use it in my nested-groups coding.

While I'm not opposed to patching the usage formatting in bits and pieces, we 
should do so while fully aware of the big picture.  Little patches tend to make 
brittle code even more brittle.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29553>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to