Пример #1
0
    def __set_item_from_slice(self, indices, iterable):
        offset = 0
        last = 0
        value_iter = iter(iterable)

        # First replace and delete if from_slice > to_slice
        for i in range(*indices):
            try:
                value = next(value_iter)
                self.__set_item(i, value)
            except StopIteration:
                self.__del_item(i)
                offset -= 1
            last = i + 1

        # Then insert if from_slice < to_slice
        for elem in value_iter:
            self.insert(last, elem)
            last += 1
Пример #2
0
    def __set_item_from_slice(self, indices, iterable):
        offset = 0
        last = 0
        value_iter = iter(iterable)

        # First replace and delete if from_slice > to_slice
        for i in range(*indices):
            try:
                value = next(value_iter)
                self.__set_item(i, value)
            except StopIteration:
                self.__del_item(i)
                offset -= 1
            last = i + 1

        # Then insert if from_slice < to_slice
        for elem in value_iter:
            self.insert(last, elem)
            last += 1
Пример #3
0
 def __repl_item_from_slice(self, range, iterable):
     value_iter = iter(iterable)
     for i in range:
         value = value = next(value_iter)
         self.__set_item(i, value)
Пример #4
0
 def __repl_item_from_slice(self, range, iterable):
     value_iter = iter(iterable)
     for i in range:
         value = value = next(value_iter)
         self.__set_item(i, value)