Small utility to extract a set of one-char options from sys.argv.

def extract_opts(**opts):
    """
    Small utility to extract a set of one-char options from sys.argv.
    """
    values = {}
    for opt, init in opts.items():
        try:
            idx = sys.argv.index('-%s' % opt)
        except ValueError:
            continue
        if idx+1 < len(sys.argv):
            opts[opt] = sys.argv.pop(idx+1)

        sys.argv.pop(idx)

    return opts