• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sliceobject.normalize_simple_slice函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.objspace.std.sliceobject.normalize_simple_slice函数的典型用法代码示例。如果您正苦于以下问题:Python normalize_simple_slice函数的具体用法?Python normalize_simple_slice怎么用?Python normalize_simple_slice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了normalize_simple_slice函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setslice__List_ANY_ANY_ANY

def setslice__List_ANY_ANY_ANY(space, w_list, w_start, w_stop, w_sequence):
    length = len(w_list.wrappeditems)
    start, stop = normalize_simple_slice(space, length, w_start, w_stop)

    sequence2 = space.listview(w_sequence)
    items = w_list.wrappeditems
    _setitem_slice_helper(space, items, start, 1, stop-start, sequence2,
                          empty_elem=None)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:8,代码来源:listobject.py


示例2: descr_getslice

 def descr_getslice(self, space, w_start, w_stop):
     selfvalue = self._val(space)
     start, stop = normalize_simple_slice(space, len(selfvalue), w_start,
                                          w_stop)
     if start == stop:
         return self._empty()
     else:
         return self._sliced(space, selfvalue, start, stop, self)
开发者ID:Darriall,项目名称:pypy,代码行数:8,代码来源:stringmethods.py


示例3: getslice__RangeList_ANY_ANY

def getslice__RangeList_ANY_ANY(space, w_rangelist, w_start, w_stop):
    if w_rangelist.w_list is not None:
        return space.getslice(w_rangelist.w_list, w_start, w_stop)
    length = w_rangelist.length
    start, stop = normalize_simple_slice(space, length, w_start, w_stop)
    slicelength = stop - start
    assert slicelength >= 0
    rangestart = w_rangelist.getitem_unchecked(start)
    rangestep = w_rangelist.step
    return W_RangeListObject(rangestart, rangestep, slicelength)
开发者ID:enyst,项目名称:plexnet,代码行数:10,代码来源:rangeobject.py


示例4: getslice__StringSlice_ANY_ANY

def getslice__StringSlice_ANY_ANY(space, w_str, w_start, w_stop):
    length = w_str.stop - w_str.start
    start, stop = normalize_simple_slice(space, length, w_start, w_stop)
    sl = stop - start
    if sl == 0:
        return W_StringObject.EMPTY
    else:
        s = w_str.str
        start = w_str.start + start
        stop = w_str.start + stop
        return W_StringSliceObject(s, start, stop)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:11,代码来源:strsliceobject.py


示例5: test_normalize_simple_slice

    def test_normalize_simple_slice(self):
        space = self.space
        w = space.wrap

        def getslice(length, start, stop):
            # returns range(length)[start:stop] but without special
            # support for negative start or stop
            return [i for i in range(length) if start <= i < stop]

        assert getslice(10, 2, 5) == [2, 3, 4]

        for length in range(5):
            for start in range(-2*length-2, 2*length+3):
                for stop in range(-2*length-2, 2*length+3):
                    mystart, mystop = normalize_simple_slice(space, length,
                                                             w(start), w(stop))
                    assert 0 <= mystart <= mystop <= length
                    assert (getslice(length, start, stop) ==
                            getslice(length, mystart, mystop))
开发者ID:Darriall,项目名称:pypy,代码行数:19,代码来源:test_sliceobject.py


示例6: getslice__List_ANY_ANY

def getslice__List_ANY_ANY(space, w_list, w_start, w_stop):
    length = len(w_list.wrappeditems)
    start, stop = normalize_simple_slice(space, length, w_start, w_stop)
    return W_ListObject(w_list.wrappeditems[start:stop])
开发者ID:gorakhargosh,项目名称:pypy,代码行数:4,代码来源:listobject.py


示例7: delslice__List_ANY_ANY

def delslice__List_ANY_ANY(space, w_list, w_start, w_stop):
    length = len(w_list.wrappeditems)
    start, stop = normalize_simple_slice(space, length, w_start, w_stop)
    _delitem_slice_helper(space, w_list.wrappeditems, start, 1, stop-start)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:4,代码来源:listobject.py


示例8: getslice__Tuple_ANY_ANY

def getslice__Tuple_ANY_ANY(space, w_tuple, w_start, w_stop):
    length = len(w_tuple.wrappeditems)
    start, stop = normalize_simple_slice(space, length, w_start, w_stop)
    return space.newtuple(w_tuple.wrappeditems[start:stop])
开发者ID:ieure,项目名称:pypy,代码行数:4,代码来源:tupleobject.py


示例9: descr_getslice

 def descr_getslice(self, space, w_start, w_stop):
     length = self.length()
     start, stop = normalize_simple_slice(space, length, w_start, w_stop)
     return space.newtuple(self.tolist()[start:stop])
开发者ID:abhinavthomas,项目名称:pypy,代码行数:4,代码来源:tupleobject.py


示例10: getslice__Unicode_ANY_ANY

def getslice__Unicode_ANY_ANY(space, w_uni, w_start, w_stop):
    uni = w_uni._value
    start, stop = normalize_simple_slice(space, len(uni), w_start, w_stop)
    return W_UnicodeObject(uni[start:stop])
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:unicodeobject.py


示例11: setslice__List_ANY_ANY_ANY

def setslice__List_ANY_ANY_ANY(space, w_list, w_start, w_stop, w_sequence):
    length = len(w_list.wrappeditems)
    start, stop = normalize_simple_slice(space, length, w_start, w_stop)
    _setitem_slice_helper(space, w_list, start, 1, stop-start, w_sequence)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:4,代码来源:listobject.py



注:本文中的pypy.objspace.std.sliceobject.normalize_simple_slice函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python stdtypedef.StdTypeDef类代码示例发布时间:2022-05-27
下一篇:
Python register_all.register_all函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap