#!/usr/local/bin/python2 from collections import Mapping, MappingView class DictView(Mapping, MappingView): __slots__ = () def __getitem__(self, key): return self._mapping[key] def __iter__(self): return iter(self._mapping) d = DictView({1:1, 2:2})