def __iter__(self):
        # Try getting the keys, if this is a dictionary view.
        try:
            keys = self.keys()
            for key in keys:
                yield key

        except ConfigTypeError:
            # Otherwise, try iterating over a list.
            collection = self.get()
            if not isinstance(collection, (list, tuple)):
                raise ConfigTypeError(
                    u'{0} must be a dictionary or a list, not {1}'.format(
                        self.name, type(collection).__name__
                    )
                )

            # Yield all the indices in the list.
            for index in range(len(collection)):
                yield self[index]
Probably not the most efficient example.
dataset/ETHPy150Open beetbox/beets/beets/util/confit.py/ConfigView.__iter__--crossover with--dataset/ETHPy150Open kdart/pycopia/core/pycopia/inet/fcgi.py/test_app