title: Python argparse - Grouping parent parser arguments into groups
body: <p>Is there a way to group the arguments from parent parsers into different groups? I don't have access to the parent parser itself, so I can't add the group there. (I'm using Google's OAuth2 framework).</p>
  
  <p>Currently my code is:</p>
  
  <pre><code># test.py
  from argparse import ArgumentParser
  from oauth2client import tools
  
  parser = ArgumentParser(description="My program", parents=[tools.argparser])
  parser.add_argument("--foo", help="Foo the data")
  parser.add_argument("--bar", help="Bar the data")
  
  parser.parse_args()
  </code></pre>
  
  <p>Which produces the following help:</p>
  
  <pre><code>$ python test.py -h                                    
  usage: test.py [-h] [--auth_host_name AUTH_HOST_NAME]
                 [--noauth_local_webserver]
                 [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
                 [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                 [--foo FOO] [--bar BAR]
  
  My program
  
  optional arguments:
    -h, --help            show this help message and exit
    --auth_host_name AUTH_HOST_NAME
                          Hostname when running a local web server.
    --noauth_local_webserver
                          Do not run a local web server.
    --auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]
                          Port web server should listen on.
    --logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                          Set the logging level of detail.
    --foo FOO             Foo the data
    --bar BAR             Bar the data
  </code></pre>
  
  <p>So, I would like to create a group for arguments from the parent parser. Is is possible to group the arguments to look something like this?</p>
  
  <pre><code>optional arguments:
    -h, --help            show this help message and exit
    --foo FOO             Foo the data
    --bar BAR             Bar the data
  
  authentication options:
    --auth_host_name AUTH_HOST_NAME
                          Hostname when running a local web server.
    --noauth_local_webserver
                          Do not run a local web server.
    --auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]
                          Port web server should listen on.
    --logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                          Set the logging level of detail.
  </code></pre>
  
  <p>I know about parser groups, but I need to somehow get the arguments from one place to another something like:</p>
  
  <pre><code>auth_group = parser.add_argument_group('authentication options')
  for arg in get_args_from_parser(tools.argparser):
      auth_group.add_argument(arg)
  </code></pre>
  
  <p>But I can't find a way to list arguments like that or copy them from one place to another.</p>