New submission from Alexandre Badez:

Hi,

Here is a sample of what I do:

>>> import argparse
>>> main_parser = argparse.ArgumentParser()
>>> group_ex = main_parser.add_mutually_exclusive_group()
>>> group_ex1 = group_ex.add_argument_group()
>>> group_ex1.add_argument('-a', '--atest', help="help about -a") and None
>>> group_ex1.add_argument('-b', '--btest', help="help about -b") and None
>>> group_ex.add_argument('-c', '--ctest', help="help about -c") and None
>>> main_parser.print_help()
usage: [-h] [-a ATEST] [-b BTEST] [-c CTEST]

optional arguments:
  -h, --help            show this help message and exit
  -c CTEST, --ctest CTEST
                        help about -c



Here is what I would except as help message:

>>> main_parser.print_help()
usage: [-h] [[-a ATEST] [-b BTEST]] | [-c CTEST]

optional arguments:
  -h, --help            show this help message and exit
  -c CTEST, --ctest CTEST
                        help about -c

  -a ATEST, --atest ATEST
                        help about -a
  -b BTEST, --btest BTEST
                        help about -b

                                                
Options '-a' and '-b' are not displayed in the help message due to the 
"add_mutually_exclusive_group".

----------
components: Library (Lib)
files: test_arg.py
messages: 247465
nosy: Alexandre.Badez
priority: normal
severity: normal
status: open
title: argparse add_mutually_exclusive_group do not print help
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file40038/test_arg.py

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

Reply via email to