Raymond Hettinger showed a really cool way to combine collection classes:
from collections import Counter, OrderedDict
class OrderedCounter(Counter, OrderedDict):
pass
# if pickle support is desired, see original post
I want to do something similar for OrderedDict and defaultdict. But of course, defaultdict has a different __init__
signature, so it requires extra work. What's the cleanest way to solve this problem? I use Python 3.3.
I found a good solution here: https://stackoverflow.com/a/4127426/336527, but I was thinking maybe deriving from defaultdict might make this even simpler?