== What past problems of mine the collections module solves The somewhat new [[collections module http://docs.python.org/library/collections.html]] has a number of useful things that obsolete several of the things I've done by hand in the past. For my own reference if nothing else, here's more or less what its solutions obsolete and when each solution was introduced. * _defaultdict_ obsoletes [[my use AccumulatorSetdefault]] of _dict.setdefault()_. It was introduced in Python 2.5. * _namedtuple_ obsoletes some but not all of my various forms of [[structures EmulatingStructsInPython]] in Python. It was introduced in Python 2.6. The reason _namedtuple_ doesn't cover all of [[my uses ListsWithNamedFields]] of (abstract) structures with named fields is right there in the name. Since it is based on tuples, you can't have modifyable structures; this makes _namedtuple_ a good match for functions that want to return structured read-only information, but not for [[more general uses LinesWithSeparatedFields]] where you want ordered named fields that you can change. (I suspect that the Pythonic view is that one should just go straight to full [[structures]] and add ordering there, instead of trying to hijack lists. A proper discussion of the issue does not fit within the margins of this entry.) Unfortunately, I'm not going to get to use the [[collections module]] very much any time soon; most of our systems are old enough that they are running Python 2.4, and that's not likely to change. Even the more recent and fast-moving ones are only on Python 2.5, and based on the speed of updates around here, it will probably be at least a year before I'm using Python 2.6 anywhere. (For the curious: Solaris 10, Red Hat Enterprise 5, and Ubuntu 6.06 all have Python 2.4 and are almost sure to stay that way for their lifetimes. Ubuntu 8.04 and Fedora 10 have Python 2.5, although it looks like the next version of Fedora will have 2.6.)