title: Multiple positional arguments with Python and argparse
body: <p>I'm trying to use argparse to parse the command line arguments for a program I'm working on. Essentially, I need to support multiple positional arguments spread within the optional arguments, but cannot get argparse to work in this situation. In the actual program, I'm using a custom action (I need to store a snapshot of the namespace each time a positional argument is found), but the problem I'm having can be replicated with the <code>append</code> action:</p>
  
  <pre><code>&gt;&gt;&gt; import argparse
  &gt;&gt;&gt; parser = argparse.ArgumentParser()
  &gt;&gt;&gt; parser.add_argument('-a', action='store_true')
  &gt;&gt;&gt; parser.add_argument('-b', action='store_true')
  &gt;&gt;&gt; parser.add_argument('input', action='append')
  &gt;&gt;&gt; parser.parse_args(['fileone', '-a', 'filetwo', '-b', 'filethree'])
  usage: ipython [-h] [-a] [-b] input
  ipython: error: unrecognized arguments: filetwo filethree
  </code></pre>
  
  <p>I'd like this to result in the namespace <code>(a=True, b=True, input=['fileone', 'filetwo', 'filethree'])</code>, but cannot see how to do this - if indeed it can. I can't see anything in the docs or Google which says one way or the other if this is possible, although its quite possible (likely?) I've overlooked something. Does anyone have any suggestions?</p>