Skip to content

Instantly share code, notes, and snippets.

@singingwolfboy
Created May 19, 2015 14:05
Show Gist options
  • Save singingwolfboy/2fdc586072af86981fcd to your computer and use it in GitHub Desktop.
Save singingwolfboy/2fdc586072af86981fcd to your computer and use it in GitHub Desktop.
from collections import defaultdict
data = defaultdict(lambda: defaultdict(dict))
# populate the data structure
for row in table:
data[row.make][row.model][row.lotnum] = color
# read the data structure
for make, models in data.items():
for model, lots in models.items():
for lotnum, color in lots.items():
# do whatever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment