'Returns a dictionary where each key is associated with a list of values.'

def dict_of_lists(self):

    r = {}
    for (key, val) in self.items():
        r.setdefault(key, []).append(val)
    return r
