title: How do you convert command line args in python to a dictionary?
body: <p>I'm writing an application that takes arbitrary command line arguments, and then passes them onto a python function:</p>
  
  <pre><code>$ myscript.py --arg1=1 --arg2=foobar --arg1=4
  </code></pre>
  
  <p>and then inside myscript.py:</p>
  
  <pre><code>import sys
  argsdict = some_function(sys.argv)
  </code></pre>
  
  <p>where <code>argsdict</code> looks like this:</p>
  
  <pre><code>{'arg1': ['1', '4'], 'arg2': 'foobar'}
  </code></pre>
  
  <p>I'm sure there is a library somewhere that does this, but I can't find anything.</p>
  
  <p><strong>EDIT:</strong> argparse/getopt/optparse is not what I'm looking for. These libraries are for defining an interface that is the same for each invocation. I need to be able to handle arbitrary arguments. </p>
  
  <p>Unless, argparse/optparse/getopt has functionality that does this...</p>