title: Argparse: how to distinguish between arguments for parsers and subparsers
body: <p>I want to use python-argparse with arguments and positional arguments. Say I have my script  on a commandline (which is just a simple&amp;stupid example), this is my code so far:</p>
  
  <pre><code>#!/usr/bin/env python
  import argparse
  
  parser = argparse.ArgumentParser()
  parser.add_argument('--verbose', action='store_true')
  subparsers = parser.add_subparsers(help='command', dest='command')
  cmd1_parser = subparsers.add_parser('command1')
  cmd1_parser.add_argument('--verbose', action='store_true')
  
  args = parser.parse_args()
  
  print args
  </code></pre>
  
  <p>Now I call this script like this:</p>
  
  <pre><code>~ $ myscript --verbose command1 --verbose
  Namespace(command='command1', verbose=True)
  
  ~ $ myscript command1 --verbose
  Namespace(command='command1', verbose=True)
  
  ~ $ myscript --verbose command1
  Namespace(command='command1', verbose=True)
  </code></pre>
  
  <p>Now as you can see I always get the same Namespace-object, and cannot distinguish if the verbose command is a regular parameter or a subparser parameter.
  But I need that to handle these parameters separately.
  What would be an easy way (with minimum code efforts) to do that? </p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>I filed an issue inside the Python stdlib issue tracker:
  <a href="http://bugs.python.org/issue15327" rel="nofollow">http://bugs.python.org/issue15327</a></p>