I want to allow arbitrary command line arguments. If the user provides me with a command line that looks like this
myscript.py --a valueofa --b valueofb posarg1 posarg2
I know that a
was passed with valueofa
, b
passed with valueofb
and that I have these last two positional arguments.
I've always used optparse, for which you specify exactly which arguments to look for. But I want the user to be able to define arbitrary "macros" from the command line. Surely there's a python module that does it more elegantly than anything I'd write. What is?