from collections import OrderedDict


class AttrDict(OrderedDict):
    def __init__(self, *args, **kwargs):
        super(AttrDict, self).__init__(*args, **kwargs)

    def __getattr__(self, attr):
        if attr not in self:
            raise AttributeError(attr)
        else:
            return self[attr]

    def __setattr__(self, attr, value):
        self[attr] = value

from collections import OrderedDict


class AttrDict(OrderedDict):
    def __init__(self, *args, **kwargs):
        super(OrderedDict, self).__init__(*args, **kwargs)

    def __getattribute__(self, attr):
        if attr in self:
            return self[attr]
        else:
            return super(OrderedDict, self).__getattribute__(attr)

    def __setattr__(self, attr, value):
        self[attr] = value

Switch use of getattr to getattribute.