How to subclass an OrderedDict?
How to subclass an OrderedDict? Question: Subclassing a Python dict works as expected: >>> class DictSub(dict): … def __init__(self): … self[1] = 10 … >>> DictSub() {1: 10} However, doing the same thing with a collections.OrderedDict does not work: >>> import collections >>> class OrdDictSub(collections.OrderedDict): … def __init__(self): … self[1] = 10 … >>> OrdDictSub() …