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


Python __builtin__.range方法代碼示例

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


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

示例1: get_range_parameters

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import range [as 別名]
def get_range_parameters(data):
        """Gets the start, stop, and step parameters from a range object"""
        # seems we only have indexing ops to infer
        # rather than direct accessors
        if len(data) > 1:
            step = data[1] - data[0]
            stop = data[-1] + step
            start = data[0]
        elif len(data):
            start = data[0]
            stop = data[0] + 1
            step = 1
        else:
            start = stop = 0
            step = 1

        return start, stop, step

    # import iterator versions of these functions 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:21,代碼來源:__init__.py

示例2: combinations

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import range [as 別名]
def combinations(iterable, r):
        # combinations('ABCD', 2) --> AB AC AD BC BD CD
        # combinations(lrange(4), 3) --> 012 013 023 123
        pool = tuple(iterable)
        n = len(pool)
        if r > n:
            return
        indices = lrange(r)
        yield tuple(pool[i] for i in indices)
        while True:
            for i in reversed(lrange(r)):
                if indices[i] != i + n - r:
                    break
            else:
                return
            indices[i] += 1
            for j in range(i+1, r):
                indices[j] = indices[j-1] + 1
            yield tuple(pool[i] for i in indices) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:21,代碼來源:python.py

示例3: elements

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import range [as 別名]
def elements(self):
        """Iterator over elements repeating each as many times as its count.

        >>> c = Counter('ABCABC')
        >>> sorted(c.elements())
        ['A', 'A', 'B', 'B', 'C', 'C']

        If an element's count has been set to zero or is a negative number,
        elements() will ignore it.

        """
        for elem, count in iteritems(self):
            for _ in range(count):
                yield elem

    # Override dict methods where the meaning changes for Counter objects. 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:__init__.py

示例4: elements

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import range [as 別名]
def elements(self):
        '''Iterator over elements repeating each as many times as its count.

        >>> c = Counter('ABCABC')
        >>> sorted(c.elements())
        ['A', 'A', 'B', 'B', 'C', 'C']

        If an element's count has been set to zero or is a negative number,
        elements() will ignore it.

        '''
        for elem, count in iteritems(self):
            for _ in range(count):
                yield elem

    # Override dict methods where the meaning changes for Counter objects. 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:18,代碼來源:pandas_py3k.py

示例5: lrange

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import range [as 別名]
def lrange(*args, **kwargs):
        return list(range(*args, **kwargs)) 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:4,代碼來源:__init__.py

示例6: oldrange

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import range [as 別名]
def oldrange(*args, **kwargs):
        return list(builtins.range(*args, **kwargs)) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:4,代碼來源:noniterators.py


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