title: argparse subcommands with nested namespaces
body: <p>Does <a href="http://docs.python.org/2.7/library/argparse.html" rel="noreferrer">argparse</a> provide built-in facilities for having it parse groups or parsers into their own namespaces? I feel like I must be missing an option somewhere.</p>
  
  <p><em>Edit</em>: This example is probably not exactly what I should be doing to structure the parser to meet my goal, but it was what I worked out so far. My specific goal is to be able to give subparsers groups of options that are parsed into namespace fields. The idea I had with parent was simply to use common options for this same purpose.</p>
  
  <p>Example:</p>
  
  <pre class="lang-py prettyprint-override"><code>import argparse
  
  # Main parser
  main_parser = argparse.ArgumentParser()
  main_parser.add_argument("-common")
  
  # filter parser
  filter_parser = argparse.ArgumentParser(add_help=False)
  filter_parser.add_argument("-filter1")
  filter_parser.add_argument("-filter2")
  
  # sub commands
  subparsers = main_parser.add_subparsers(help='sub-command help')
  
  parser_a = subparsers.add_parser('command_a', help="command_a help", parents=[filter_parser])
  parser_a.add_argument("-foo")
  parser_a.add_argument("-bar")
  
  parser_b = subparsers.add_parser('command_b', help="command_b help", parents=[filter_parser])
  parser_b.add_argument("-biz")
  parser_b.add_argument("-baz")
  
  # parse
  namespace = main_parser.parse_args()
  print namespace
  </code></pre>
  
  <p>This is what I get, obviously:</p>
  
  <pre><code>$ python test.py command_a -foo bar -filter1 val
  Namespace(bar=None, common=None, filter1='val', filter2=None, foo='bar')
  </code></pre>
  
  <p>But this is what I am really after:</p>
  
  <pre><code>Namespace(bar=None, common=None, foo='bar', 
            filter=Namespace(filter1='val', filter2=None))
  </code></pre>
  
  <p>And then even more groups of options already parsed into namespaces:</p>
  
  <pre><code>Namespace(common=None, 
            foo='bar', bar=None,  
            filter=Namespace(filter1='val', filter2=None),
            anotherGroup=Namespace(bazers='val'),
            anotherGroup2=Namespace(fooers='val'),
            )
  </code></pre>
  
  <p>I've found a <a href="https://stackoverflow.com/questions/15782948/how-to-have-sub-parser-arguments-in-separate-namespace-with-argparse">related question here</a> but it involves some custom parsing and seems to only covers a really specific circumstance.</p>
  
  <p>Is there an option somewhere to tell argparse to parse certain groups into namespaced fields?</p>