當前位置: 首頁>>代碼示例>>Python>>正文


Python six.Iterator方法代碼示例

本文整理匯總了Python中six.Iterator方法的典型用法代碼示例。如果您正苦於以下問題:Python six.Iterator方法的具體用法?Python six.Iterator怎麽用?Python six.Iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在six的用法示例。


在下文中一共展示了six.Iterator方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __next__

# 需要導入模塊: import six [as 別名]
# 或者: from six import Iterator [as 別名]
def __next__(self):
        if self._done:
            raise GraknError('Iterator was already iterated.')

        try:
            response = next(self._response_iterator)
        except StopIteration:
            raise GraknError('Internal client/protocol error,'
                             ' did not receive an expected "done" or "iteratorId" message.'
                             '\n\n Please ensure client version is supported by server version.')

        iter_res = response.iter_res
        res_type = iter_res.WhichOneof('res')
        if res_type == 'done':
            self._done = True
            raise StopIteration
        elif res_type == 'iteratorId':
            self._request_next_batch(iter_res.iteratorId)
            return next(self)
        else:
            return self._resp_converter(iter_res) 
開發者ID:graknlabs,項目名稱:client-python,代碼行數:23,代碼來源:TransactionService.py

示例2: is_iterator

# 需要導入模塊: import six [as 別名]
# 或者: from six import Iterator [as 別名]
def is_iterator(obj):
    return isinstance(obj, collections.Iterator) 
開發者ID:openstack,項目名稱:yaql,代碼行數:4,代碼來源:utils.py

示例3: memorize

# 需要導入模塊: import six [as 別名]
# 或者: from six import Iterator [as 別名]
def memorize(collection, engine):
    if not is_iterator(collection):
        return collection

    yielded = []

    class RememberingIterator(six.Iterator):
        def __init__(self):
            self.seq = iter(collection)
            self.index = 0

        def __iter__(self):
            return RememberingIterator()

        def __next__(self):
            if self.index < len(yielded):
                self.index += 1
                return yielded[self.index - 1]
            else:
                val = next(self.seq)
                yielded.append(val)
                limit_memory_usage(engine, (1, yielded))
                self.index += 1
                return val

    return RememberingIterator() 
開發者ID:openstack,項目名稱:yaql,代碼行數:28,代碼來源:utils.py

示例4: query

# 需要導入模塊: import six [as 別名]
# 或者: from six import Iterator [as 別名]
def query(self, query, infer, explain, batch_size):
        return Iterator(self._communicator,
                        RequestBuilder.start_iterating_query(query, infer, explain, batch_size),
                        ResponseReader.ResponseReader.get_query_results(self)) 
開發者ID:graknlabs,項目名稱:client-python,代碼行數:6,代碼來源:TransactionService.py

示例5: get_attributes_by_value

# 需要導入模塊: import six [as 別名]
# 或者: from six import Iterator [as 別名]
def get_attributes_by_value(self, attribute_value, value_type):
        request = RequestBuilder.start_iterating_get_attributes_by_value(attribute_value, value_type)
        return Iterator(self._communicator, request, ResponseReader.ResponseReader.get_attributes_by_value(self)) 
開發者ID:graknlabs,項目名稱:client-python,代碼行數:5,代碼來源:TransactionService.py

示例6: run_concept_iter_method

# 需要導入模塊: import six [as 別名]
# 或者: from six import Iterator [as 別名]
def run_concept_iter_method(self, concept_id, grpc_concept_iter_method_req):
        return Iterator(self._communicator,
                        RequestBuilder.start_iterating_concept_method(concept_id, grpc_concept_iter_method_req),
                        lambda res: res.conceptMethod_iter_res.response) 
開發者ID:graknlabs,項目名稱:client-python,代碼行數:6,代碼來源:TransactionService.py

示例7: test_iterator

# 需要導入模塊: import six [as 別名]
# 或者: from six import Iterator [as 別名]
def test_iterator():
    class myiter(six.Iterator):
        def __next__(self):
            return 13
    assert six.advance_iterator(myiter()) == 13
    class myitersub(myiter):
        def __next__(self):
            return 14
    assert six.advance_iterator(myitersub()) == 14 
開發者ID:benjaminp,項目名稱:six,代碼行數:11,代碼來源:test_six.py


注:本文中的six.Iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。