def __len__(self):
        """Calling len(s) will consume the generator."""
        try:
            while True:
                self.__next()
        except StopIteration:
            pass
        return self.__size()
Calling len(s) will consume the generator.
recipes/Python/534114_List_wrapper_generators_indexable/recipe-534114.py