data = {} for result in results: try: data[result.type] += [result] except: data[result.type] = [result]