Typically one may simply call optparse's method parse_args without any arguments. If, however, one needs to supply a different argument set than that of sys.argv, if may be passed to parse_args.
But what does one do if one needs to pass a string, not a list to parse_args?
I really need a function that does this:
>>> argument_string = "-a arga -b \"argument b\" arg1 arg2"
>>> parse_arguments(argument_string)"
['-a', 'arga', '-b', 'argument b', 'arg1', 'arg2']
Because
>>> argument_string.split(" ")
['-a', 'arga', '-b', '"argument', 'b"', 'arg1', 'arg2']
doesn't cut it. Any thoughts?