Tag Archives: dict

A dict and an object, all in one.

I’ve been struggling with data modeling decisions for my MongoDB interface layer.  Should results from the DB look like a dict, or like an object?  Like both?  What are the advantages and disadvantages of each approach?  I’ve got my own … Continue reading

Posted in General | Tagged , , | Leave a comment

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

Multi-dimensional dicts in Python & Django?

The code I’m working on frequently uses multi-dimensional dicts in Python.  There is a bunch of code that seems to be always doing this: # a,b, and c have come from some external data source, QuerySet, etc. a = ‘axis_1′ … Continue reading

Posted in General | Tagged , , , , | 5 Comments