def iteritems(self): if isinstance(self._items, dict): for key, value in iteritems(self._items): yield key, value else: for i, item in enumerate(self._items): yield i, item
def items(self): if isinstance(self._items, dict): return list(iteritems(self._items)) else: return enumerate(self._items)
def __init__(self, **attrs): for key, value in iteritems(attrs): setattr(self, key, value)