Argparse: Default values not shown for subparsers
<p>I have the problem that I am not seeing any default values for arguments when specifying them via add_argument for subparsers using the argparse Python package.</p>

<p>Some research said that you need non-empty help-parameters set for each add_argument step and you need ArgumentDefaultsHelpFormatter as formatter_class as described here:</p>

<p><a href="https://stackoverflow.com/questions/12151306/argparse-way-to-include-default-values-in-help">Argparse: Way to include default values in &#39;--help&#39;?</a></p>

<p>That's not working for me, however. I suspect that somehow the subparser defaults are suppressed.</p>

<p>Here's an example:</p>

<pre><code>from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter

parser = ArgumentParser(description="Sample script", formatter_class=ArgumentDefaultsHelpFormatter, version="sample version")

# Initialize Subparsers

subparsers = parser.add_subparsers(help="", dest="command")

# foo command

fooparser = subparsers.add_parser('foo', help='Do foo')
fooparser.add_argument('files', action='store', help='Foo file(s)' , nargs="+")
fooparser.add_argument("-5", "--Do5", type=int, required=False, dest="do5", help="Do 5 subprocedure.")
fooparser.add_argument("-n", "--topn", type=int, required=False, dest="topn", default=1, help="Show topn")

# bar command

barparser = subparsers.add_parser('bar', help='Do bar')
barparser.add_argument('files', action='store', help='Bar file(s)' , nargs="+")
barparser.add_argument("-mq", "--min-mq", type=int, required=False, default=2, dest="mq", help="Minimum MQ")
barparser.add_argument("-mi", "--min-identity", type=float, required=False, default=0.95, dest="identity", help="Minimum identity")

args = parser.parse_args()
</code></pre>