当前位置: 首页>>代码示例>>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;未经允许,请勿转载。