I'm writing an application that takes arbitrary command line arguments, and then passes them onto a python function:
$ myscript.py --arg1=1 --arg2=foobar --arg1=4
and then inside myscript.py:
import sys
argsdict = some_function(sys.argv)
where argsdict
looks like this:
{'arg1': ['1', '4'], 'arg2': 'foobar'}
I'm sure there is a library somewhere that does this, but I can't find anything.
EDIT: 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.
Unless, argparse/optparse/getopt has functionality that does this...