Tag Archives: defaultdict

Python Multi-dimensional dicts using defaultdict

I asked previously how to avoid code like this: # Implement d[3][4] = 5 if not 3 in d: d[3] = {} d[3][4] = 5 I found the answer, and it lies in collections.defaultdict. defaultdict is just like dict, except … Continue reading

Posted in General | Tagged , , | 3 Comments