Convert Tuple List to Dictionary
""" | |
usage: | |
mytool [options] | |
options: | |
--foo-bar=PARAM1,PARAM2,... params to do stuff with | |
[default: key1.value1,key1.value2,key2.value2] | |
""" | |
from docopt import docopt | |
from collections import defaultdict | |
def run(): | |
params = [tuple(param.strip().split('.')) for param in arguments["--foo-bar"].split(",")] | |
params = convert_tuple_list_to_dictionary(ignored_resources) | |
def convert_tuple_list_to_dictionary(list_of_tuple): | |
dictionary = defaultdict(list) | |
for k, v in list_of_tuple: | |
dictionary[k].append(v) | |
return dictionary | |
if __name__ == "__main__": | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment