Пример #1
0
 def extend(self, objects):
     """
     Extends the list with the given `objects`.
     """
     if self.exhausted:
         self._collected_data.extend(objects)
     else:
         self._iterator = chain(self._iterator, objects)
Пример #2
0
 def extend(self, objects):
     """
     Extends the list with the given `objects`.
     """
     if self.exhausted:
         self._collected_data.extend(objects)
     else:
         self._iterator = chain(self._iterator, objects)
Пример #3
0
    def elements(self):
        """
        Iterator over the elements in the counter, repeating as many times as
        counted.

        >>> from brownie.datastructures import Counter
        >>> sorted(Counter('abcabc').elements())
        ['a', 'a', 'b', 'b', 'c', 'c']
        """
        return chain(*starmap(repeat, self.iteritems()))
Пример #4
0
 def __add__(self, other):
     if isinstance(other, (list, self.__class__)):
         return self.__class__(chain(self, other))
     raise TypeError("can't concatenate with non-list: {0}".format(other))
Пример #5
0
 def symmetric_difference(self, other):
     other = self.__class__(other)
     return self.__class__(chain(self - other, other - self))
Пример #6
0
 def __add__(self, other):
     if isinstance(other, (list, self.__class__)):
         return self.__class__(chain(self, other))
     raise TypeError("can't concatenate with non-list: {0}".format(other))
Пример #7
0
 def symmetric_difference(self, other):
     other = self.__class__(other)
     return self.__class__(chain(self - other, other - self))
Пример #8
0
def test_chain():
    list(chain([1, 2], [3, 4])) == [1, 2, 3, 4]
    list(chain.from_iterable([[1, 2], [3, 4]])) == [1, 2, 3, 4]
Пример #9
0
def test_chain():
    Assert(list(chain([1, 2], [3, 4]))) == [1, 2, 3, 4]
    Assert(list(chain.from_iterable([[1, 2], [3, 4]]))) == [1, 2, 3, 4]
Пример #10
0
def test_chain():
    Assert(list(chain([1, 2], [3, 4]))) == [1, 2, 3, 4]
    Assert(list(chain.from_iterable([[1, 2], [3, 4]]))) == [1, 2, 3, 4]
Пример #11
0
def test_chain():
    list(chain([1, 2], [3, 4])) == [1, 2, 3, 4]
    list(chain.from_iterable([[1, 2], [3, 4]])) == [1, 2, 3, 4]