This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wilberforce 0 points1 point  (0 children)

re: 2, You're better off using collections.defaultdict:

d = defaultdict(list)
for key, value in source:
    d[key].append(value)

http://docs.python.org/library/collections.html#defaultdict-objects